0
我有問題將對象傳遞給MVVM light WPF中的輔助視圖。我有主視圖模型。 follow of operation。我能夠使用MVVM light和Modren UI導航服務進行連接。問題是我無法將主要客戶視圖模型的對象發送到輔助視圖模型。我想從源視圖模型設置目標視圖的數據上下文。我已經嘗試過,但似乎沒有工作。我更喜歡沒有代碼,我花了很多時間沒有成功。WPF MVVM Light和modren UI-將對象傳遞到輔助視圖
public virtual void NavigateTo(string pageKey, object parameter)
{
lock (_pagesByKey)
{
if (!_pagesByKey.ContainsKey(pageKey))
{
throw new ArgumentException(string.Format("No such page: {0}. Did you forget to call NavigationService.Configure?", pageKey), "pageKey");
}
var frame = GetDescendantFromName(Application.Current.MainWindow, "ContentFrame") as ModernFrame;
// Set the frame source, which initiates navigation
if (frame != null)
{
frame.Source = _pagesByKey[pageKey];
//i Dont know if this should work or not
frame.DataContext = parameter;
}
Parameter = parameter;
_historic.Add(pageKey);
CurrentPageKey = pageKey;
}
}
任何幫助將不勝感激。我只需要如何設置目標視圖的datacontext而不使用代碼。謝謝