I have a ListView with four columns ComputerName, IP, Status, UseMachine (String, String, String, Checkbox) I just want to disable the checkbox for the ListViewItem where Status = "Running" How can I do that? Here is the code I am using:
<Window.Resources>
<Style x:Key="ItemContStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Style.Resources>
<LinearGradientBrush x:Key="InactiveBrush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0.1" Color="#AACC0000" />
<GradientStop Offset="0.8" Color="#55880000" />
</LinearGradientBrush>
<local:StringBackgroundConverter x:Key="RedBackgroundIfNotStarted" />
</Style.Resources>
<Style.Triggers>
<DataTrigger Binding="{Binding Status, Converter={StaticResource RedBackgroundIfNotStarted}}" Value="0">
<Setter Property="Background" Value="{StaticResource InactiveBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
And then...
<ListView Height="178" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Margin="10,6,0,0" Name="ServerGridView" VerticalAlignment="Top" Width="500" ItemsSource="{Binding}" ItemContainerStyle="{StaticResource ItemContStyle}" SelectionChanged="ServerGridView_SelectionChanged">
<ListView.View>
<GridView >
<GridViewColumn DisplayMemberBinding="{Binding ComputerName}">
<GridViewColumnHeader HorizontalContentAlignment="Center" Content="Computer Name"></GridViewColumnHeader>
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding IPAddress}">
<GridViewColumnHeader HorizontalContentAlignment="Center" Content="IP Address"></GridViewColumnHeader>
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Status}">
<GridViewColumnHeader HorizontalContentAlignment="Center" Content="Status"></GridViewColumnHeader>
</GridViewColumn>
<GridViewColumn>
<GridViewColumnHeader HorizontalContentAlignment="Center" Content="Machine Selected"></GridViewColumnHeader>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<CheckBox HorizontalAlignment="Center" Style="{StaticResource CheckBoxEnabledStyle}" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>