当我选择一个 listboxItem 时,我想更改前景色,我使用了这段代码:
<DataTrigger Binding="{Binding
RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
<Setter TargetName="descriptionTB" Property="Foreground" Value="#000"/>
</DataTrigger>
你可以找到答案here .
但是,如果我希望设计师在 Blend 中执行此操作,他将如何在不钻研 xaml 的情况下做到这一点?
谢谢
最佳答案
阿图尔,
Expression Blend 中的触发器设计器仅允许添加和修改 EventTriggers 和 Property 触发器。我还没有找到使用 Blend 添加 DataTriggers 的方法。我也不确定如何使用 Blend 设置relativeSource Binding。我总是将 XAML 交给代码进行测试,并使用 Blend 处理其他所有事情。
关于使用 Blend 为 ListBox 项目的 DataTemplate 中 IsSelected 的 WPF 触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/615268/