我将x:Bind与mode=OneWay一起使用。
<CommandBar
DefaultLabelPosition="Bottom"
RelativePanel.RightOf="AutoSuggestBoxSearchItem">
<AppBarButton
x:Name="DetailsButton"
Icon="Contact"
Label="View details"
IsEnabled="{x:Bind converters:Converters.IsNotNull(ViewModel.SelectedItem), Mode=OneWay}"/>
<AppBarButton
x:Name="DeleteButton"
Icon="Delete"
Label="Delete"
IsEnabled="{x:Bind converters:Converters.IsNotNull(ViewModel.SelectedItem), Mode=OneWay}"/>
<AppBarSeparator/>
<AppBarButton
x:Name="AddButton"
Icon="Add"
Label="Add"/>
如果对象不为IsNotNull,则检查“%s”。
public class Converters
{
public static bool IsNotNull(object value) => value != null;
}ViewModel.SectedItem在数据网格中显示所选项目。因此,当我在DataGrid中选择项时,应用程序栏按钮必须将属性isEnabled设置为true。
但是:2 first button on the top must be available, but thay aren't
发布于 2018-10-06 02:44:37
创建一个属性并将其绑定到IsEnabled,如下所示IsEnabled="{x:Bind propertyName)“
在属性设置器上使用OnPropertyChanged("propertyName")
https://stackoverflow.com/questions/52669399
复制相似问题