You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
<Window x:Class="DataTemplateSample.MainWindow"
|
|
|
|
|
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:local="clr-namespace:DataTemplateSample"
|
|
|
|
|
xmlns:custom="clr-namespace:DataTemplateSample.Custom"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
Title="MainWindow" Height="200" Width="200">
|
|
|
|
|
<Window.Resources>
|
|
|
|
|
<local:Person x:Key="person"/>
|
|
|
|
|
|
|
|
|
|
<DataTemplate DataType="{x:Type local:Person}">
|
|
|
|
|
<StackPanel Orientation="Vertical">
|
|
|
|
|
<TextBlock>Hello,</TextBlock>
|
|
|
|
|
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
|
|
|
|
|
<TextBlock>Your age is </TextBlock>
|
|
|
|
|
<TextBlock Text="{Binding Age}" FontWeight="Bold"/>
|
|
|
|
|
<TextBlock>Right?</TextBlock>
|
|
|
|
|
<custom:Test/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</Window.Resources>
|
|
|
|
|
|
|
|
|
|
<ContentControl Content="{StaticResource person}">
|
|
|
|
|
|
|
|
|
|
</ContentControl>
|
|
|
|
|
</Window>
|