【发布时间】:2017-03-06 23:48:36
【问题描述】:
在我的 UWP 中,CanExecute 处理程序不会被触发。这是我的代码:
中继命令
EditWorkItemEntry = new RelayCommand(async () =>
{
var diag = new EditWorkItemEntryDialog(SelectedWorkItem);
await diag.ShowAsync();
await ReloadWorkItems();
}, () =>
{
return SelectedWorkItem != null;
});
使用命令的代码:
<mt:MtPage.BottomAppBar>
<CommandBar>
<AppBarButton Icon="Edit" x:Uid="EditWorkItemEntry" Command="{x:Bind ViewModel.EditWorkItemEntry, Mode=OneWay}" />
</CommandBar>
</mt:MtPage.BottomAppBar>
以及应该触发它的代码:
<mtControls:DataGrid ItemsSource="{Binding WorkItems}" SelectedItem="{x:Bind ViewModel.SelectedWorkItem, Mode=OneWay}">
<!-- More definition logic -->
</mtControls:DataGrid>
mtControls:DataGrid 映射到 MyToolkit DataGrid,可以在这里找到:https://github.com/MyToolkit/MyToolkit/tree/master/src/MyToolkit.Extended/Controls/DataGrid
有人知道为什么它没有被调用吗?
【问题讨论】: