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();
}
}
有什么特别的,我必须做的,因为我使用的用户控件?也许是不同的命名空间是问题?