Note that there are some explanatory texts on larger screens.

plurals
  1. POConditional formating of a TextBlock within a Listbox’s DataTemplate
    primarykey
    data
    text
    <p>It’s my first wcf &amp; I’m running into some trouble with what seems to be a basic XAML concept.</p> <p>Somehow the DataTrigger / Binding in the “PriorityStyle” is not working. I guess this is because of a context issue but looking around I haven’t manage to find the answers.</p> <pre><code>&lt;UserControl … &gt; &lt;UserControl.Resources&gt; &lt;Style x:Key="PriorityStyle" TargetType="TextBlock" &gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Priority}" Value="High"&gt; &lt;Setter Property="Foreground" Value="Red"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;DataTemplate x:Key="ItemTemplate"&gt; &lt;StackPanel Margin="3"&gt; ... &lt;DockPanel&gt; &lt;TextBlock Name="Priority" Text="{Binding Priority}" Foreground ="#014f7c" Style="{StaticResource PriorityStyle}"/&gt; &lt;/DockPanel&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;DataTemplate x:Key="SelectedTemplate"&gt; ... &lt;/DataTemplate&gt; &lt;Style TargetType="{x:Type ListBoxItem}" x:Key="ContainerStyle"&gt; &lt;Setter Property="ContentTemplate" Value="{StaticResource ItemTemplate}" /&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsSelected" Value="True"&gt; &lt;Setter Property="ContentTemplate" Value="{StaticResource SelectedTemplate}" /&gt; &lt;/Trigger&gt; &lt;!-- DataBinding work in this Context, But in Style I cannot use a TargetName --&gt; &lt;DataTrigger Binding="{Binding Priority}" Value="High"&gt; &lt;Setter Property="Background" Value="DarkOrange"/&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;ListBox x:Name="ListBox" ItemContainerStyle="{StaticResource ContainerStyle}" /&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload