OwnerDrawListBox.xaml 1.5 KB

123456789101112131415161718192021222324252627
  1. <ListBox x:Class="CustomControls.OwnerDrawListBox"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:CustomControls="clr-namespace:CustomControls">
  5. <ListBox.Resources>
  6. <Style x:Key="ItemContainerStyle1" TargetType="{x:Type ListBoxItem}">
  7. <Setter Property="Template">
  8. <Setter.Value>
  9. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  10. <CustomControls:OwnerDrawListBoxItem x:Name="item" SnapsToDevicePixels="true"/>
  11. <ControlTemplate.Triggers>
  12. <Trigger Property="IsSelected" Value="True">
  13. <Setter Property="IsSelectedChanged" TargetName="item" Value="true"/>
  14. </Trigger>
  15. <Trigger Property="IsEnabled" Value="False">
  16. <Setter Property="IsEnabledChanged" TargetName="item" Value="true"/>
  17. </Trigger>
  18. <Trigger Property="IsMouseOver" Value="True">
  19. <Setter Property="IsMouseOverChanged" TargetName="item" Value="true"/>
  20. </Trigger>
  21. </ControlTemplate.Triggers>
  22. </ControlTemplate>
  23. </Setter.Value>
  24. </Setter>
  25. </Style>
  26. </ListBox.Resources>
  27. </ListBox>