There are many views that look alike, but there are differences. But the general view is similar. I wrote a sample view as a base. It has an element ContentControl = "AreaUser_1" in which I would like to insert my view. Is there a way to access this item from another Xaml? Example: Base (sample)

<UserControl x:Class="PCCD.View.TemlateSingleSettingsView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ignore="http://www.galasoft.ch/ignore" mc:Ignorable="d ignore" xmlns:localVM="clr-namespace:PCCD.ViewModel" xmlns:localV="clr-namespace:PCCD.View" > <UserControl.Resources> <ResourceDictionary> <DataTemplate DataType="{x:Type localVM:LinkTable_RTUViewModel}"> <localV:LinkTable_RTUView /> </DataTemplate> <DataTemplate DataType="{x:Type localVM:LinkTable_COMViewModel}"> <localV:LinkTable_COMView /> </DataTemplate> </ResourceDictionary> </UserControl.Resources> <Grid x:Name="GridTest" x:FieldModifier="public" > <Grid.RowDefinitions> <RowDefinition /> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Name}" Margin="2" /> <ContentControl x:Name="AreaUser_1" Grid.Column="1" Grid.Row="0" Content="{Binding AreaUser1}" /> <ContentControl Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Content="{Binding LinkSettingsVM}" /> </Grid> </UserControl> 

Here is the xaml that needs to be addressed by AreaUser_1

  <UserControl x:Class="PCCD.View.DeviceSettingsView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ignore="http://www.galasoft.ch/ignore" mc:Ignorable="d ignore" xmlns:localVM="clr-namespace:PCCD.ViewModel" xmlns:localV="clr-namespace:PCCD.View" > <UserControl.Resources> <DataTemplate DataType="{x:Type localVM:TemlateSingleSettingsViewModel}"> <localV:TemlateSingleSettingsView /> </DataTemplate> <localV:TemlateSingleSettingsView x:Key="Templ"> </localV:TemlateSingleSettingsView> <Grid x:Key="Area1" x:Name="AreaUser1"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Button x:Name="DeviceAdd" Grid.Column="0" Margin="2" Width="16" Content="+" Command="{Binding Path=AddDevice}" /> <Button x:Name="DeviceRemove" Grid.Column="1" Margin="{Binding ElementName=DeviceAdd, Path=Margin}" Height="{Binding ElementName=DeviceAdd, Path=Height}" Width="{Binding ElementName=DeviceAdd, Path=Width}" Content="-" Command="{Binding Path=RemoveDevice}" /> </Grid> </UserControl.Resources> <Grid> <ContentControl x:Name="ContT" Content="{StaticResource Templ}"> </ContentControl> </Grid> </UserControl> 
  • It seems you need this: ru.stackoverflow.com/a/765122/10105 . Only ContentPresenter will need to be inserted not at the window level, but instead of <ContentControl x:Name="AreaUser_1" . - VladD
  • Not exactly what you need. The link tells the substitution view. And I need to cram in that content, for example, a button for one, for another combobox, while both views will be displayed - Konstantin Mefodev
  • If you need to display multiple views, put an ItemsControl in the XAML, and add VM elements to the VM. Display each VM element via DataTemplate. - VladD
  • @ Konstantin Mefodiev Did you manage to think of anything? The solution to this issue is also of interest, so far nothing has been found .. - Badalov Badal
  • one
    How exactly to contact from Xaml to Xaml did not find. I did it differently: Let's say that in the "Base" our AreaUser1 is called AreaUser1ViewModel. In the "Heir", we use the DataTemplate to associate an AreaUser1ViewModel with the required View - Konstantin Mefodev

0