私はDLToolkit.Forms.Controls.FlowListView(daniel-luberda)を使用して、ボタン付きグリッドビューを表示するUWPで動作するXamarin.Formsアプリケーションを使用しています。Xamarin.Forms ChangeCanExecuteが正しいパラメータを使用していません
使用されるMvvmフレームワークはFreshMvvmです。ここで
は、XAMLで私のGridViewのである:ここでは
<c:FlowListView SeparatorVisibility="None"
HasUnevenRows="False" FlowColumnMinWidth="100"
FlowItemsSource="{Binding Boards}">
<c:FlowListView.FlowColumnTemplate>
<DataTemplate>
<Button Text="{Binding Number}"
Command="{Binding Path=BindingContext.SelectBoardCommand, Source={x:Reference Name=SalesPage}}"
CommandParameter="{Binding .}" />
</DataTemplate>
</c:FlowListView.FlowColumnTemplate>
</c:FlowListView>
は(私はXAMLに関する色とサイズを簡素化)の結果である:
私のGridViewの内側のボタンがにバインドされパラメータ付きのコマンド。私がボタンをクリックするたびに、私はそれを無効にしたいと思います。ボタンを押す
private ICommand _selectBoardCommand;
[DoNotNotify]
public ICommand SelectBoardCommand => _selectBoardCommand = new Command<BoardModel>(board =>
{
board.NotUsed = false;
((Command<BoardModel>) _selectBoardCommand).ChangeCanExecute();
}, board => board != null && board.NotUsed);
は、右のパラメータを指定してコマンドを呼び出します(コマンドのテキストにバインドさboard.Numberが、私はコマンドで取得するものです):
そして、私のコマンドは次のようになります。 しかし、コマンドを無効にするために "CanChangeExecute"を呼び出すと、選択したボードを引数として渡すことができません。
((Command<BoardModel>) _selectBoardCommand).ChangeCanExecute();
を使用して、リストの最新アイテムとのFunc
board => board != null && board.NotUsed
を呼び出し
そしてコマンドで、。
また、ChangeCanExecuteに "board!= null"を入れる必要があったのは、このFuncがヌル値で多くの時間と呼ばれていたからです。
FlowListViewに問題はありませんか? – Andy
@Andyちょうどテストされた同じ問題 – hugoterelle