0
我有一個名爲EditorView的UserControl,根據其內容顯示不同的「編輯器」(其他用戶控件)。XAML綁定到ContentControl的UserControl的屬性
這是EditorView只是爲了測試結合我替換TextBlock中的字體編輯器:
<UserControl x:Class="TrikeEditor.UserInterface.EditorView" ...>
<UserControl.Resources>
<DataTemplate DataType="{x:Type te_texture:Texture}">
<teuied:TextureEditor TextureName="{Binding Path=Name}"/>
</DataTemplate>
<DataTemplate DataType="{x:Type te_font:Font}">
<!--<teuied:FontEditor/>-->
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</UserControl.Resources>
<UserControl.Template>
<ControlTemplate TargetType="{x:Type UserControl}">
<ContentPresenter Content="{TemplateBinding Content}" x:Name="EditorPresenter"/>
</ControlTemplate>
</UserControl.Template>
</UserControl>
合適的模板是基於EditorView.Content和TextBlock的情況下,結合作品越來越選爲期望,但在TextureEditor的情況下,TextureName屬性不是。
下面是從TextureEditor片段:
public partial class TextureEditor : UserControl
{
public static readonly DependencyProperty TextureNameProperty = DependencyProperty.Register("TextureName", typeof(string), typeof(TextureEditor));
public string TextureName
{
get { return (string)GetValue(TextureNameProperty); }
set { SetValue(TextureNameProperty, value); }
}
public TextureEditor()
{
InitializeComponent();
}
}
有什麼特別的,我必須做的,因爲我使用的用戶控件?也許是不同的命名空間是問題?