Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

wpf open new Window in MVVM

public class ViewModel
{
    private readonly IWindowFactory m_windowFactory;
    private ICommand m_openNewWindow;

    public ViewModel(IWindowFactory windowFactory)
    {
        m_windowFactory = windowFactory;

        /**
         * Would need to assign value to m_openNewWindow here, and associate the DoOpenWindow method
         * to the execution of the command.
         * */
        m_openNewWindow = null;  
    }

    public void DoOpenNewWindow()
    {
        m_windowFactory.CreateNewWindow();
    }

    public ICommand OpenNewWindow { get { return m_openNewWindow; } }
}

public interface IWindowFactory
{
    void CreateNewWindow();
}

public class ProductionWindowFactory: IWindowFactory
{

    #region Implementation of INewWindowFactory

    public void CreateNewWindow()
    {
       NewWindow window = new NewWindow
           {
               DataContext = new NewWindowViewModel()
           };
       window.Show();
    }

    #endregion
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: secret 
Csharp :: obs mfplat.dll 
Csharp :: how to define a static color resource in xaml wpf 
Csharp :: appodeal unity integration 
Csharp :: calculator using single readline c# 
Csharp :: C# Read Excel columns header return to list 
Csharp :: what is string args in c# 
Csharp :: c# Isolation Levels 
Csharp :: stringbuilder sb = new stringbuilder(reallylongstring); you need to identify whether a string stored in an object named stringtofind is within the stringbuilder sb object. 
Csharp :: Area Of the triangle with condition 
Csharp :: vb.net tostring numeric format string 
Csharp :: custom vs code snippet 
Csharp :: maximum sum of non-adjacent 
Csharp :: change text color wpf 
Csharp :: app rating within game in unity 
Csharp :: C#: casting string to enum object 
Csharp :: c# application exit 
Csharp :: web scraping dynamic content c# 
Csharp :: inverse kinematics not working unity 
Csharp :: come controllare se textbox è vuota c# 
Csharp :: population of the world 
Html :: how to link css to html 
Html :: regex href html pattern 
Html :: call link html 
Html :: editable div 
Html :: html facebook meta tags 
Html :: html import css 
Html :: submit form on change 
Html :: bootstrap flex align 
Html :: twig foreach key value 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =