2013-07-22 59 views
0

我有使用從我的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 

但現在我的主窗口被合併到另一個項目,並改製爲MVVM稱爲「MapView」的對象,可以爲不同的用途構建。 我的問題是如何從轉換器訪問MapView對象以獲取MapView.SelectedLayerItems?

+1

您不能從轉換器訪問任何視圖。你在這裏混合了完全不同的概念。你需要做什麼? –

回答

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 
相關問題