我有一个转换器用于从我的MainWindow类中获取属性:
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
ObservableCollection<string[]> selectedItems = mainWindow.SelectedLayerItems; // A collection of layer items
但现在我的MainWindow已经与另一个项目合并,并被重新组织成一个名为'MapView'的mvvm对象,可以构建用于不同的用途。 我的问题是如何从转换器访问MapView对象以获取MapView.SelectedLayerItems?
答案 0 :(得分:0)
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
dynamic mainWindow = Application.Current.MainWindow;
ObservableCollection<string[]> selectedItems = mainWindow.SelectedLayerItems; // A collection of layer items