我有一个继承自 ViewModelBase 的类。我需要从其他类设置getter setter。如何得到这个
public class UserScreenViewModel : ViewModelBase
{
public UserScreenViewModel()
{
this.Items = new ObservableCollection<TabDataItem>();
try
{
.....
var allLayouts = context.PANEL_LAYOUTS;
foreach (var layouts in allLayouts)
{
TabDataItem item = new TabDataItem()
{
Header = layouts.Header,
};
this.Items.Add(item);
}
}
this.SelectedTabItem = this.Items[0];
}
}
public ObservableCollection<TabDataItem> Items { get; set; }
private TabDataItem selectedItem;
/// <summary>
/// Gets or sets the SelectedTabItem.
/// </summary>
public TabDataItem SelectedTabItem
{
get
{
return this.selectedItem;
}
internal set
{
if (this.selectedItem != value)
{
this.selectedItem = value;
OnPropertyChanged("SelectedTabItem");
}
}
}
}
现在我需要从其他类设置 SelectedTabItem 而不是“this.SelectedTabItem = this.Items[0]”。如何做到这一点?