Imagine that in one data template I have a text field and another data template, I have two text fields.
In accordance with this, there is a flag in the view and each template is shown .. is this possible?
Sorry if my question is so in doubt, I studied it, but I did not recognize it.
I did it, I know that it is useless, but only for testing.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <DataTemplate DataType="{x:Type ContentControl}" x:Key="T1"> <StackPanel> <TextBox Height="20" /> </StackPanel> </DataTemplate> <DataTemplate DataType="{x:Type ContentControl}" x:Key="T2"> <StackPanel> <TextBox Height="20" /> <TextBox Height="20" /> </StackPanel> </DataTemplate> </Window.Resources> <Grid> <ContentControl Template="{StaticResource T1}" /> </Grid> </Window>
Darf zon
source share