XAML 是否有办法在触发器中保留多个条件

mw3dktmi  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(139)

我正在使用xamarin.forms。在xaml中,我希望使用triggers,如下所示

if(Theme=="Operational" && Selected == true)
//set properties
else if(Theme=="Digital" && Selected == true)
//set properties

ThemeSelectedbinding属性。目前我正在根据上述条件导航到不同的xaml页面。我正在尝试这样的triggers

<Grid.Triggers>
  <DataTrigger
     Binding="{Binding TabButtons[0].BtnSelected}"
     TargetType="Grid"
     Value="True">
     <Setter Property="IsVisible" Value="False" />
  </DataTrigger>
</Grid.Triggers>

我该怎么做?

kr98yfug

kr98yfug1#

尝试像这样使用MultiTrigger

<Grid.Triggers>
    <MultiTrigger TargetType="Grid">
        <MultiTrigger.Conditions>
            <BindingCondition Binding="{Binding Theme}" Value="OPERATIONAL" />
            <BindingCondition Binding="{Binding Selected }" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="IsVisible" Value="False" />
    </MultiTrigger>
    <MultiTrigger TargetType="Grid">
        <MultiTrigger.Conditions>
            <BindingCondition Binding="{Binding Theme}" Value="DIGITAL" />
            <BindingCondition Binding="{Binding Selected}" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="IsVisible" Value="True" />
    </MultiTrigger>
</Grid.Triggers>

相关问题