I'm creating a kind of base WPF application to host WPF user controls, that will come in an assembly (later this will be AddIns). The application and the user control are following MVVM. Unfortunately I'm new to WPF and MVVM, so I am not that familiar with the specials. I have searched a lot, but nothing that helped me (or I didn't understand the solution, that might be possible).
So my application contains basic functionality for the user controls and a window that is split into a menu bar and the placeholder for the user control. This is what I have so far, there is a button to choose the VersionControl control, which will call a function in the viewModel of my MainWindow where I load the user control, but I do not get it to be shown in the MainWindow.
<Grid DataContext="{StaticResource Windows1ViewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Canvas Grid.Row="0" >
<Button Content="VersionControl"
Style="{StaticResource ButtonStyle1}"
HorizontalAlignment="Center"
Command="{Binding LoadVersionControl}" />
</Canvas>
<Canvas Grid.Row="1">
<ItemsControl Name="ControlCanvas" />
</Canvas>
</Grid>
The ViewModel definitions:
public ICommand LoadVersionControl { get { return new DelegateCommand(OnLoadVersionControl); } }
But what do I need to do in the OnLoadVersionControl function? I have the VersionControlView and VersionControlViewModel, but no idea how to get it shown in my application. Many thanks for your help,
Mike