开发者

What's the easiest way to do negation in triggers?

开发者 https://www.devze.com 2022-12-08 08:41 出处:网络
I want to do something like <DataTrigger Binding=\"{Binding Someth开发者_C百科ing}\" ValueIsNot=\"{x:Null}\">

I want to do something like

<DataTrigger Binding="{Binding Someth开发者_C百科ing}" ValueIsNot="{x:Null}">


I think your best bet is to use a Converter. See this blog post for a sample for converting a result into a boolean.

<DataTrigger
    Binding="{Binding Path=x, Converter={StaticResource IsNotNullConverter}}"
    Value="true">


If you want to go with triggers, you could write your own or leverage existing ones. If you're doing MVVM, just bind the view to a property on your VM that does the logic for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消