You could try to refer to the code below.
App.xaml.cs:
<Application.Resources>
<local:ViewModel x:Key="SharedViewModel" />
</Application.Resources>
MainWindow.xaml and ViewModel:
264596-content-control-two-view-on-viewmodel.txt
View1:
<UserControl
...
DataContext="{StaticResource SharedViewModel}">
<Canvas>
<TextBlock Text="{Binding Name}" Width="100" Height="50" Background="LightPink" Margin="50"/>
<Line x:Name="lin1" Stroke="Gray" StrokeThickness="2" X1="30" X2="30" Y1="20" Y2="40"/>
<Line x:Name="lin2" Stroke="Blue" StrokeThickness="2" X1="40" X2="40" Y1="20" Y2="40"/>
<Line x:Name="lin3" Stroke="Red" StrokeThickness="2" X1="50" X2="50" Y1="20" Y2="40"/>
</Canvas>
</UserControl>
View2:
<UserControl
...
DataContext="{StaticResource SharedViewModel}" >
<Canvas>
<Button Content="{Binding Address}" Width="100" Height="50" Background="AliceBlue" Margin="70"/>
<Line x:Name="lin1" Stroke="Gray" StrokeThickness="2" X1="30" X2="130" Y1="40" Y2="40"/>
<Line x:Name="lin2" Stroke="Blue" StrokeThickness="2" X1="30" X2="120" Y1="50" Y2="50"/>
<Line x:Name="lin3" Stroke="Red" StrokeThickness="2" X1="30" X2="120" Y1="60" Y2="60"/>
</Canvas>
</UserControl>
The result:
----------------------------------------------------------------------------
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.