Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create this trigger
Message
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01474336
Message ID:
01474404
Views:
52
>I have a collection of classes together in a tree. The whole collection is bound to a TreeView. One of the classes has a bool property on called IsChanged:
>
>
>public class ReportColumn
>{
>    public string ColumnName { get; set; }
>    public object OriginalValue { get; set; }
>    public object ChangedValue { get; set; }
>    public bool IsChanged { get; set; }
>}
>
>
>In my XAML I created a DataTemplate for it:
>
><DataTemplate DataType="{x:Type local:ReportColumn}"
>    <StackPanel Orientation="Horizontal"
>
>        <!-- Column Name --
>        <TextBlock Margin="0,0,5,0" 
>                    FontWeight="Bold"Name:</TextBlock
>        <TextBlock Text="{Binding Path=ColumnName}"</TextBlock
>
>        <!-- Original Value --
>        <TextBlock Margin="20,0,5,0" 
>                    FontWeight="Bold"Original:</TextBlock
>        <TextBlock Text="{Binding Path=OriginalValue}"</TextBlock
>
>        <!-- Changed Value --
>        <TextBlock Margin="20,0,5,0" 
>                    FontWeight="Bold"Change:</TextBlock
>        <TextBlock Text="{Binding Path=ChangedValue}"</TextBlock
>
>    </StackPanel
></DataTemplate
>
>Then the whole thing is bound to the treeview. What I'd like is to make this node's foreground red when IsChanged is true. Can someone explain how to do this?
<DataTemplate.Triggers>
        <DataTrigger Binding="{Binding Path=IsChanged}" Value="true">
               <Setter Property="TextBlock.Foreground" Value="Red"/>
         </DataTrigger>
 </DataTemplate.Triggers>
Previous
Reply
Map
View

Click here to load this message in the networking platform