WPF 4.6我有一个列表网格,并希望打开一个基于行选择,传递ID的视图。我越来越没有传递到新的细节:MVVMCross WPF网格行命令没有通过参数
电网ListView的XAML
<DataGridTemplateColumn Width="Auto">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<Button Content="Edit Line"
Command="{Binding DataContext.EditClientLineCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding}"
Margin="5" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
ListViewModel(CustomerInfo是行项目)
public DetailsParameters _thisparams; //simple class with int index only
我设置的时候选择了一行:
public CustomerInfo SelectedCustomer
{
get { return _selectedCustomer; }
set
{
_selectedCustomer = value;
_thisparams.Index = _selectedCustomer.Id;
RaisePropertyChanged(() => SelectedCustomer);
}
}
然后作为参数传递
private MvxCommand<CustomerInfo> _goToDetails;
public MvxCommand<CustomerInfo> EditClientLineCommand
{
get { return _goToDetails ??
(_goToDetails = new MvxCommand<CustomerInfo>
(SelectedCustomer => {
ShowViewModel<CustomerDetailViewModel>
(_thisparams);}
)
);
}
}
和DetailViewModel启动地区:
public void Init(DetailsParameters thisid)
{
_customerId = thisid.Index;
}
customerId
是0
而且,后来我退了出去,并重新选择另一行,我得到的细节(仍然没有分配的),但没有命中Init断点..
更好的XAML也许,但没有修复。我认为我在早期版本... – tdrake
@tdrake请发送您的代码的其他部分。 – Ron