Есть стиль ListViewItem:
<Style TargetType="ListViewItem">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="local:Properties.IsStatus" Value="{Binding IsStatus, Mode=OneWay}" />
<Setter Property="local:Properties.IsConnection" Value="{Binding IsConnection, Mode=OneWay}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border x:Name="Border" Padding="0">
<ContentPresenter
x:Name="Content"
Margin="0,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="local:Properties.IsStatus" Value="0" />
<Condition Property="local:Properties.IsConnection" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<!-- Красный -->
<Setter Property="Background" Value="#FFFFCDD2" />
<Setter Property="Foreground" Value="#FFB71C1C" />
<Setter Property="BorderBrush" Value="#00D32F2F" />
</MultiTrigger.Setters>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="local:Properties.IsStatus" Value="1" />
<Condition Property="local:Properties.IsConnection" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<!-- Оранжевый -->
<Setter Property="Background" Value="#FFFFE0B2" />
<Setter Property="Foreground" Value="#FFE65100" />
<Setter Property="BorderBrush" Value="#00F57C00" />
</MultiTrigger.Setters>
</MultiTrigger>
... (тут может несколько вариантов подобных установок)
...
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFFFE0B2" />
<Setter Property="Foreground" Value="#FFE65100" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="local:Properties.IsConnection" Value="False" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter Property="Background" Value="#FFFFFFFF" />
<Setter Property="Foreground" Value="#FF000000" />
<Setter Property="BorderBrush" Value="#00000000" />
</MultiTrigger.Setters>
</MultiTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFE8EAF6" />
<Setter Property="Foreground" Value="#FF1A237E" />
</Trigger>
</Style.Triggers>
</Style>
И есть шаблон данных:
<DataTemplate DataType="{x:Type host_com:Host_Device_Items}">
<DataTemplate.Resources>
<local:IntToBooleanConverter x:Key="IntToBoolConverter" />
</DataTemplate.Resources>
<ListViewItem local:Properties.IsConnection="{Binding IsConnection}" local:Properties.IsStatus="{Binding IsStatus}">
<Border >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="8*" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="12*" />
<ColumnDefinition Width="4*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
HorizontalAlignment="Right"
Content="{Binding Index}"
Foreground="{Binding Foreground}" />
<Label
Grid.Column="1"
Margin="5,0,0,0"
Padding="0"
HorizontalAlignment="Left"
Content="{Binding Name}"
Foreground="{Binding Foreground}" />
<RadioButton
Grid.Column="2"
local:Properties.IsStatusFalse="9"
local:Properties.IsStatusTrue="0"
Content="Выключен"
IsChecked="{Binding Selected, Converter={StaticResource IntToBoolConverter}, ConverterParameter=0}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=Self}}" />
<RadioButton
Grid.Column="3"
local:Properties.IsStatusFalse="9"
local:Properties.IsStatusTrue="3"
Content="1"
IsChecked="{Binding Selected, Converter={StaticResource IntToBoolConverter}, ConverterParameter=1}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=Self}}" />
<RadioButton
Grid.Column="4"
local:Properties.IsStatusFalse="9"
local:Properties.IsStatusTrue="3"
Content="2"
IsChecked="{Binding Selected, Converter={StaticResource IntToBoolConverter}, ConverterParameter=2}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource Mode=Self}}" />
</Grid>
</Border>
</ListViewItem>
</DataTemplate>
Раньше шаблон данных располагался в стиле, в Template. Но поскольку мне понадобился второй вариант списка, то старый вариант уже не подходит. Пришлось вынести в отдельный шаблон. Но возникла проблема: перестали работать триггеры. Как решить эту проблему?