To style a simple Lisbox, we can trigger change of property by either looking at other property or data loaded
<Style TargetType="{x:Type ListBoxItem}" >
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Foreground" Value="Red" />
</Trigger>
<DataTrigger Binding="{Binding Path=Name}" Value="User 3">
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
...
list.Add(new User(){ Name="User 1"});
list.Add(new User() { Name = "User 2" });
listBox1.ItemsSource = list;
Saturday, June 2, 2012
Style Trigger and DataTrigger
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment