我父視圖模型包含幾個子視圖模型,它看起來像父視圖模型遺棄兒童視圖模型的屬性
public MainViewModel:ObservableObject
{
public MainViewModel(){//initalize everything};
private SomeViewModel childvm1;
private AnotherViewModel childvm2;
public SomeViewModel Childvm1
{
get
{
return childvm1;
}
set
{
SetField(ref childvm1, value, "Childvm1");
}
}
public AnotherViewModel Childvm2
{
get
{
return childvm2;
}
set
{
SetField(ref childvm2, value, "Childvm2");
}
}
//when this changes i want to notify childvm2 and call a function in it
public SomeModel SelectedValueofChildvm1
{
get
{
return Childvm1.SelectedValue;
}
}
}
我怎麼能調用一個函數在childvm2
時SelectedValueofChildvm1
變化?
如果沒有'set','SelectedValueofChildvm1'如何改變? –
設置在childvm1中,我是否也必須在此處公開它? – FPGA
您是否需要對價值的變化做出反應,還是隻是試圖使其可以綁定? – CodingGorilla