<ItemsControl Name="workingCardsPanel">
<ItemsControl.Triggers>
<Trigger SourceName="workingCardsPanel" Property="HasItems" Value="True">
<Setter TargetName="workingCardsPanel" Property="BorderThickness" Value="1"/>
<Setter TargetName="workingCardsPanel" Property="BorderBrush" Value="#FF828790"/>
</Trigger>
</ItemsControl.Triggers>
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Style.Triggers>
</Style.Triggers>
</Style>
</ItemsControl.Style>
<ItemsControl.Items>
<ListBoxItem><TextBlock Text="Hello world!"/></ListBoxItem>
</ItemsControl.Items>
</ItemsControl>
When the ItemsControl has items, I want to set its BorderThickness
and BorderBrush
to corresponding values as demonstrated above.
However the code is not compilable.
I have already managed it when I move the setters to Style.Triggers
. I just want to know whether ItemsControl.Triggers
can do it. Or if it cannot, what does ItemsControl.Triggers used for?
One more question.
<ItemsControl>
<ItemsControl.Triggers>
<Trigger Property="HasItems" Value="True">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#FF828790"/>
</Trigger>
</ItemsControl.Triggers>
I'm wonder if it is possible that all properties(HasItems, BorderThickness, and BorderBrush) refer to ones of the control without its name. (as the ItemsControl does not have a name now.)
Thank you.