i created my first WPF MVVM pattern solution. I created a UserControl and I would like to reuse this control in my MainWindow, because style is the same only differents between this both controls are the datasource. First Control uses ObervableCollection index 0 and second UserControl uses from the same OberservableCollection index 1. The observablecollection is in my Mainviewmodel and the binding works well, if I make the binding inside of my UserControl.
Dont want to bind inside of the UserControl to my model like this:
UserControl:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="PersonModel.FirstName"></TextBlock>
<TextBlock Grid.Row="1" Text="PersonModel.FirstName"></TextBlock>
</Grid>
I would like to bind each nested control of my Usercontrol in my MainWindow.
MainWindow.xaml
<desktop:UserControl1 Textblock1.Text="{Binding PersonModel.FirstName} TextBlock2.Text="{Binding PersonModel.LastName}"></desktop:UserControl1>