KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Lets say I have a MainWindow and a MainViewModel , I'm not using MVVM Light or Prism in this example. In this MainWindow I want to click a MenuItem or Button to open a NewWindow.xaml not a UserControl . I know how to use this with UserControl to open a new UserControl in my existing Window in a ContrntControl or a Frame . <ContentControl Content="{Binding Path=DisplayUserControl,UpdateSourceTrigger=PropertyChanged}" /> Code public ViewModelBase DisplayUserControl { get { if (displayUserControl == null) { displayUserControl = new ViewModels.UC1iewModel(); } return displayUserControl; } set { if (displayUserControl == value) { return; } else { displayUserControl = value; OnPropertyChanged("DisplayUserControl"); } } } In the ResourceDitionary for MainWindow I have : <DataTemplate DataType="{x:Type localViewModels:UC1ViewModel}"> <localViews:UC1 /> </DataTemplate> <DataTemplate DataType="{x:Type localViewModels:UC2ViewModel}"> <localViews:UC2 /> </DataTemplate> The thing is that I want to open a new Window , not a UserControl . So I use some code like this : private ICommand openNewWindow; public ICommand OpenNewWindow { get { return openNewWindow; } } public void DoOpenNewWindow() { View.NewWindowWindow validationWindow = new View.NewWindow(); NewWindowViewModel newWindowViewModel = new NewWindowViewModel(); newWindow.DataContext = ewWindowViewModel; newWindow.Show(); } and then a bind OpenN
Tags (comma-separated)
Save Edits
Cancel