I have the following data trigger on the ListBoxItems in my Multi-selection ListBox
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DisableWorkItemConverter}">
<Binding ElementName="MainForm" Path="PickedWorkItemID"/>
<Binding Path="Id"/>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="IsSelected" Value="False"/>
</DataTrigger>
IsEnabled gets set fine, but IsSelected does not get set. How can I fix that?
I tried taking out IsEnabled to see if it was conflicting with IsSelected, but the Item remained selected when it should not.
Just to reiterate, I can tell the bindings and the converter are working fine, because IsEnabled works correctly. But for some reason IsSelected will not un-set.
Edit: It just occurred to me that I may not want this to work like IsEnabled. Because when this trigger evaluates false, the item gets re-enabled. I would not want a previously unselected row to get selected just because this trigger is no longer true.
Any ideas? Basically I don't want any of the disabled rows to be selected.
Edit 2:
I tried adding a normal trigger hoping it would chain off the data trigger and that did not work either.
<Style.Triggers>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DisableWorkItemConverter}">
<Binding ElementName="MainForm" Path="PickedWorkItemID"/>
<Binding Path="Id"/>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="IsSelected" Value="False"></Setter>
</Trigger>
</Style.Triggers>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…