public static void ShowDialog <Tmodel, Tview>() where Tview : UserControl, new() where Tmodel : new() { var view = new Tview(); view.DataContext = new Tmodel(); mainWindow.MainContainer.Children.Clear(); mainWindow.MainContainer.Children.Add(view); }
public static UserControl GetView <Tmodel, Tview>() where Tmodel : new () where Tview : UserControl, new() { UserControl view; if (!Views.TryGetValue(typeof(Tmodel), out view)) { view = new Tview(); view.DataContext = new Tmodel(); Views.Add(typeof(Tmodel), view); } return(view); }