我有以下型号:
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 模型中的琐碎类型...