Avalonia.Xaml.Behaviors
Avalonia.Xaml.Behaviors copied to clipboard
DataTriggerBehavior not change property on ListBoxItem
Hi there,
I have an issue when I'm using a DataTriggerBehavior on ListboxItem. I want just to set background (after that, my final purpose is to set template and contentTemplate) on listboxItem with ChangePropertyAction like this :
<ListBox
Items="{Binding Persons}"
SelectionMode="Multiple"
x:Name="ListPerson">
<Interaction.Behaviors>
<DataTriggerBehavior Binding="{Binding SelectedPerson}" Value="{x:Static enums:PersonType.SuperUser}">
<ChangePropertyAction TargetObject="{Binding #ListPerson.Items}" PropertyName="Background"
Value="Red" />
</DataTriggerBehavior>
</ListBox>
Did I missing something on the DataTriggerBehavior current behavior because the property won't change after DataTrigger ? I have checked if the binding have the right value and it's that case.
After check, it's maybe related to this issue ? Can't use static object binding with DataTriggerBehavior Thank in advance.
What if you will use binding to the listbox directly? Like "{Binding #ListPerson.SelectfedItem}". Also in your example you actually missed SelectfedItem to SelectedPerson binding in the ListBox itself. At least this would be a problem.
Hi @maxkatz6 As basis, I wanted to change template on all ListBoxItem so I wanted to target ListPerson.Items.
Btw the workaround was your answer about this discussions about several classes styles with Avalonia :