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>
ContentPresenterwill need to be inserted not at the window level, but instead of<ContentControl x:Name="AreaUser_1". - VladD