私は次のモデルを持っています:
public class Car : BindableBase
{
private string _model;
private string _wheels;
public string Model
{
get { return _model; }
set { SetProperty(ref _model, value); }
}
public string Wheels
{
get { return _wheels; }
set { SetProperty(ref _wheels, value); }
}
}
public class Customer : BindableBase
{
private Car _car;
public Car Car
{
get { return _car; }
set { SetProperty(ref _car, value); }
}
}
バインディングは次のようになります。
<Page.Resources>
<viewModels:CustomerViewModelLocator x:Key="PageViewModel" />
</Page.Resources>
<StackPanel>
<TextBox Background="AliceBlue" Text="{Binding ViewModel.Car.Model, Mode=TwoWay, Source={StaticResource PageViewModel}}"></TextBox>
<TextBox Background="AliceBlue" Text="{Binding ViewModel.Car.Wheels, Mode=TwoWay, Source={StaticResource PageViewModel}}"></TextBox>
</StackPanel>
デザイン時のビューに ViewModelLocator パターンを使用していますが、見栄えがします。しかし、実行時にモデルのセッターをヒットしません。
私は何を間違っていますか?
Customer モデル内の自明なタイプが設定されます...