This project is read-only.

Retrieve the DataContext of the Content set by using ContentSource property.

Sep 1, 2014 at 11:16 AM
Edited Sep 1, 2014 at 11:37 AM

I need to get the DataContext of the View set by using ContentSource property of the ModernWindow, Could you please help.

Thank you.
Sep 2, 2014 at 9:51 AM
Sounds like you are having an issue with separation of concerns. What problem are you trying to solve?
Sep 2, 2014 at 4:08 PM
Hi kozw,

I had to show Prompt Messages and get the User's input and pass it onto a python script which is waiting for an input, I am using MVVM framework and I have multiple instances of the many Views and ViewModels so I had to map them with each other, I was able to solve this by setting the ModernWindow's Content manually by getting its ModernFrame from the Template I am posting the code below in case if any one would need it and I've uploaded a sample at

    public void ShowPrompt()
        this.PromptWindow = ObjectFactory.GetInstance<IPromptWindowViewModel>().Window as ModernWindow;
        this.PromptWindow.Title = string.Concat("Control ", this.PromptOriginsEntity.PromptOriginsIdentity);
        this.PromptWindow.Tag = this.PromptOriginsEntity.PromptOriginsIdentity;
        this.PromptWindow.Owner = Application.Current.MainWindow;

        // Store Window object in PromptWindowsCollection
        this.PromptWindow.Show(); // inorder to retrieve the ModernFrame the ModernWindow is to be shown first

        ModernFrame frameContent = (ModernFrame)this.PromptWindow.Template.FindName("ContentFrame", this.PromptWindow);
        UserControl userControl = new UserControl { Content = GetView<IPromptViewModel>(), Tag = this.PromptOriginsEntity.PromptOriginsIdentity };
        frameContent.Content = userControl;

        IPromptViewModel promptViewModel = (IPromptViewModel)((IView)userControl.Content).DataContext;
        promptViewModel.PromptEntity.Identity = this.PromptOriginsEntity.PromptOriginsIdentity;