なぜこれが機能するのかわかりません (単一の Car を RadDataForm にバインドします):
xaml:
<tk:RadDataForm ItemsSource="{Binding Path=Cars}"
AutoGenerateFields="True" DataContext="{Binding}" />
ビューモデル:
public void OnNavigatedTo(NavigationContext navigationContext)
{
carId = int.Parse(navigationContext.Parameters["IdRecord"]);
Cars= _carContext.GetCarById(carId);
}
private IEnumerable<Car> cars;
public IEnumerable<Car> Cars
{
get { return this.cars; }
set
{
if (this.cars!= value)
{
this.cars= value;
this.RaisePropertyChanged(() => this.Cars);
}
}
}
そしてこれはそうではありません:
xaml:
<tk:RadDataForm CurrentItem="{Binding Path=CurrentCar}"
AutoGenerateFields="True" DataContext="{Binding}" />
ビューモデル:
public void OnNavigatedTo(NavigationContext navigationContext)
{
carId = int.Parse(navigationContext.Parameters["IdRecord"]);
CurrentCar= _carContext.GetCarById(carId).FirstOrDefault();
}
private Car currentCar;
public Car CurrentCar
{
get { return this.currentCar; }
set
{
if (this.currentCar!= value)
{
this.currentCar= value;
this.RaisePropertyChanged(() => this.CurrentCar);
}
}
}
単一のエンティティを取得したいので、IEnumerable<> は必要ありません。ところで、何がうまくいかないのかを理解したいのですが...