I have a button in a ListBoxItem. I want the button to stay enabled even if the list box Item is disabled. Is this possible?
Here is my style code for the listbox, listbox item and the button (called btnPick).
<Window.Resources>
<Style x:Key="CheckBoxListStyle" TargetType="ListBox">
<Style.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid ScrollViewer.CanContentScroll="True" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<CheckBox VerticalAlignment="Center" Grid.Column="0" IsChecked="{Binding IsSelected,
RelativeSource={RelativeSource TemplatedParent},
Mode=TwoWay}" Name="chkSelectedCheckBox" />
<TextBlock VerticalAlignment="Center" Grid.Column="1" Margin="5,0,5,0" Text="{Binding Id}" />
<TextBlock VerticalAlignment="Center" Grid.Column="2" Margin="5,0,5,0" Text="{Binding Title}" />
<!--This is the one that I want to stay enabled somehow-->
<Button HorizontalAlignment="Right" x:Name="btnPick" Grid.Column="3" Tag="{Binding Id}" Margin="5,0,5,0"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DisableWorkItemConverter}">
<Binding ElementName="MainForm" Path="PickedWorkItemID"/>
<Binding Path="Id"/>
<Binding ElementName="btnCreateLink" Path="IsClicked"></Binding>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="loc:Main.IsCurrentItemEnabledChanged" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
</Window.Resources>
Right now my Data Trigger sets IsEnabled for the whole line item. Is it possible to somehow access the children of the ListBoxItem?
Something like:
<Setter Property="chkSelectedCheckBox.IsEnabled" Value="False"/>
Is what I am looking for (but that does not work). (I thought that TargetName might help me out, but that only works for DataTemplates.)
Thanks for any help.