【发布时间】:2019-02-21 18:37:47
【问题描述】:
我正在尝试将一个按钮的启用属性绑定到 UWP 中另一个按钮的选中属性。
<CommandBar DefaultLabelPosition="Right" VerticalContentAlignment="Center">
<AppBarButton Icon="Add" Label="Add Images" Command="{x:Bind ViewModel.AddImagesCommand}"/>
<AppBarSeparator/>
<AppBarToggleButton x:Name="buttonSelect" Label="Select"/>
<AppBarButton Icon="SelectAll" Label="SelectAll" Click="{x:Bind gridViewInputImages.SelectAll}" IsEnabled="{x:Bind buttonSelect.IsChecked}"/>
</CommandBar>
但是,我收到错误绑定分配无效:无法直接将类型“System.Nullable(System.Boolean)”绑定到“System.Boolean”。使用强制转换、转换器或函数绑定来更改类型
我想我可以通过绑定到 ViewModel 中的中间值来解决这个问题,但是有没有办法在 XAML 中做到这一点?
【问题讨论】: