【问题标题】:How to set IsEnabled to true when binding property is false绑定属性为 false 时如何将 IsEnabled 设置为 true
【发布时间】:2021-09-28 09:31:35
【问题描述】:

我有两个页面元素(在同一个视图中),一个依赖于另一个。仅当未选中该复选框时,我才需要启用我的条目。我可以在不创建其他属性的情况下执行此操作吗?

<Label Text="Simulate" />
<CheckBox IsChecked="{Binding Simulate}"/>

<Label Text="Route Path"/>
<Entry Text="{Binding RoutePath}" IsEnabled="{Binding Simulate}"/>

【问题讨论】:

    标签: c# xaml xamarin.forms data-binding


    【解决方案1】:

    使用 xamarin 社区工具包中的 InvertedBoolConverter 之类的值转换器:

    xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
    
    <Entry Text="{Binding RoutePath}"
           IsEnabled="{Binding Simulate, Converter={xct:InvertedBoolConverter}}"/>
    

    【讨论】:

      猜你喜欢
      • 2019-11-21
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 2019-03-19
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      相关资源
      最近更新 更多