I work with WPF 4.0. You just need to display a list of something without a choice, but scrolling if necessary. The best thing in my opinion is ListBox. Posted by following template for ListBoxItem

<UserControl.Resources> <Style x:Key="NoSelectedItemStyle" TargetType="{x:Type ListBoxItem}"> <Style.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> </Style.Resources> <Setter Property="Focusable" Value="False" /> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Transparent" /> </Trigger> </Style.Triggers> </Style> </UserControl.Resources> 

It seems everything should work according to logic, found many similar examples on the Internet. But when aiming the cursor on the Item in the ListBox, it is still highlighted with blue light. Tried to change other properties in the trigger.

  <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="Red" /> <Setter Property="Background" Value="Green" /> <Setter Property="BorderBrush" Value="Black" /> <Setter Property="BorderThickness" Value="3" /> </Trigger> 

Everything changes, except for the color of the "rectangle" of the backlight, it remains blue all the time. Border in the latter case changes the thickness, but the color also remains blue, only slightly darker. It seems that a blue rectangle is superimposed on top. How can I get rid of this blue backlight? I work in a desktop application, but in Windows 10

  • four
    For simple display of the collection (without highlighting, etc.) <ItemsControl> Bulletin - Bulson best suited
  • I know this, but I would like to try to solve it with ListBox - S_Schmal
  • one
    Wrap the ItemsControl in the ScrollViewer and use it without crutches. There will be scrolling, and the lack of choice. - Anton Papin
  • Thanks for the answer, I got to it myself, everything works fine - S_Schmal

0