Hi, @Goran Bervar . Welcome Microsoft Q&A.
You are on the right track. You would usually have a MainViewModel like
public class ViewModel
{
public ViewModel1 M1 { get; set; }
public ViewModel2 M2 { get; set; }
}
public class ViewModel1
{
public string Name1 { get; set; }
}
public class ViewModel2
{
public string Name2 { get; set; }
}
and would use it in your XAML like
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<StackPanel>
<local:UserControl1 x:Name="uc1" DataContext="{Binding M1}"/>
<local:UserControl1 x:Name="uc2" DataContext="{Binding M2}"/>
</StackPanel>
----------------------------------------------------------------------------
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.