DataTemplate (または同様のもの) がある場合、キャンバスで非 UIElements を使用する方法はありますか? 私は以前にこれをやったような気がします、そしてそれは可能だと思いますが、それを理解することはできません. ここにいくつかのコードがあります...
<Window x:Class="EntityTranslator.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EntityTranslator"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:Entity x:Key="DesignEntity}" EntityName="Test" />
<DataTemplate DataType="{x:Type local:Entity}">
<StackPanel>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<Canvas>
<local:Entity EntityName="Test" />
</Canvas>
</Grid>
</Window>