Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做类似的事情
<DataTrigger Binding="{Binding Something}" ValueIsNot="{x:Null}">
我认为你最好的选择是使用转换器。有关将结果转换为布尔值的示例,请参阅此博客文章。
<DataTrigger Binding="{Binding Path=x, Converter={StaticResource IsNotNullConverter}}" Value="true">
如果您想使用触发器,您可以编写自己的或利用现有的触发器。如果您正在执行 MVVM,只需将视图绑定到 VM 上为您执行逻辑的属性。