R – WPF Trigger for IsSelected in a DataTemplate for ListBox items with Blend

datatemplateexpression-blendlistboxwpf

I wanted to change the Foreground color when I selected a listboxItem and I did it using this bit of code:

<DataTrigger Binding="{Binding  
RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
                            <Setter TargetName="descriptionTB" Property="Foreground" Value="#000"/>
</DataTrigger>

You can find the answer here.

But if I want a designer to do this in Blend, how would he do it without drilling into xaml?

Thank you

Best Answer

Artur,

The Triggers designer in Expression Blend only allows adding and modifying EventTriggers and Property triggers. I haven't found a way to add DataTriggers with Blend. I'm also not sure how to set RelativeSource Binding using Blend either. I've always handed code the XAML for test and use Blend for everything else.

Related Topic