我有绑定到我的视图模型的列表框。这个视图模型有一个属性
我需要随着此字段的更改使该项目可见但不可点击。任何建议任何人
public interface IRegionAreaDM
{
/// <summary>
/// Name of the Focus Area
/// </summary>
string RegionAreaName { get; set; }
/// <summary>
/// Determines if the Tab is currently selected.
/// </summary>
bool IsSelected { get; set; }
/// <summary>
/// Determines if the Tab is linked to any other Tab
/// </summary>
bool IsLinked { get; set; }
/// <summary>
///
/// </summary>
bool IsActive { get; set; }
}
每个项目都连接到 XAML 中的一个项目,例如带有 Textbox 的名称。IsSelected 与 CheckBox 和 IsActive 是使 ListBoxItems 启用/禁用取决于逻辑和我的 Xaml 样式看起来像这样
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Bd" HorizontalAlignment="Stretch" Background="#00D05252"
BorderThickness="0,1" SnapsToDevicePixels="true">
<!-- <StackPanel x:Name="ParamterRoot" Orientation="Horizontal"> -->
<Grid x:Name="ParamterRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox x:Name="ParametersCheckbox" Grid.Column="0" Margin="10,0,0,0"
VerticalAlignment="Center" IsChecked="{Binding IsSelected}"
<TextBlock Grid.Column="1" Width="Auto" Margin="20,7.5,0,7.5"
Text="{Binding RegionAreaName}" TextTrimming="CharacterEllipsis">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<Trigger Property="IsMouseDirectlyOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<!-- </StackPanel> -->
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Bd" Property="Background" Value="#FFC10000" />
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Bd" Property="Background" Value="#FFC10000" />
</Trigger>
<DataTrigger Binding="{Binding IsActive}" Value="False">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>