マウスを右クリックして ContextMenu を開く XamDataGrid の項目を渡そうとしています。これにより、ViewModel で Command が発生します。コマンドが呼び出すメソッドは、デバッグ モードでは到達できません。
これはビューから切り取ったものです
<ig:XamDataGrid DataSource="{Binding DrdResults}" Height="700" Width="600">
<ig:XamDataGrid.ContextMenu>
<ContextMenu DataContext="{Binding RelativeSource={RelativeSource Mode=Self},
Path=PlacementTarget.DataContext}"
AllowDrop="True" Name="cmAudit">
<MenuItem Header="View History"
Command="{Binding ViewTradeHistory}"
CommandParameter="{Binding Path=SelectedItems}">
</MenuItem>
</ContextMenu>
</ig:XamDataGrid.ContextMenu>
<ig:XamDataGrid.FieldSettings>
<ig:FieldSettings AllowFixing="NearOrFar"
AllowEdit="False"
Width="auto" Height="auto" />
</ig:XamDataGrid.FieldSettings>
</ig:XamDataGrid>
このビューに対応する ViewModel の私のコードは次のとおりです。
public WPF.ICommand ViewTradeHistory
{
get
{
if (_viewTradeHistory == null)
{
_viewTradeHistory = new DelegateCommand(
(object SelectedItems) =>
{
this.OpenTradeHistory(SelectedItems);
});
}
return _viewTradeHistory;
}
}
最後に、コマンドによって呼び出される実際のメソッドは次のとおりです。
private void OpenTradeHistory(object records)
{
DataPresenterBase.SelectedItemHolder auditRecords
= (DataPresenterBase.SelectedItemHolder)records;
// Do something with the auditRecords now.
}
ここで何が間違っているのかわかりません。どんな助けでも大歓迎です。
ありがとう、シュラヴァン