私は次のように対応するビューでシンプルなデータ型をマッピングするためのDataTemplateを作成しようとしています:Metro XAMLで暗黙のデータテンプレートを定義する方法は?
<DataTemplate DataType="{x:Type src:Person}">
<TextBox Text="{Binding Name}"/>
</DataTemplate>
私はDataTypeプロパティが認識され、またはアクセスされていないことを示すコンパイルエラーを取得します。私はここに何かを逃していますかこれを行うための新しい構文がありますか、機能がありませんか?暗黙のテンプレートの代替ソリューションはありますか? Key属性(作品):
<UserControl x:Class="Metro_App.MainPage"
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:src="clr-namespace:Metro_App"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1366">
<UserControl.Resources>
<DataTemplate x:Key="PersonTemplate">
<TextBlock Text="{Binding Name}" Foreground="White" FontSize="72"/>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="#FF0C0C0C">
<ContentControl Content="{Binding MyPerson}" ContentTemplate="{StaticResource PersonTemplate}"/>
</Grid>
</UserControl>
しかし、興味深い 'DataTemplateKey'があります。 –
はい、そうです。おそらく暗黙的なテンプレートが途中にあることを示唆しているでしょうか? – ColinE