WPF窗口隐藏内容DependencyProperty

时间:2015-06-08 20:47:14

标签: c# wpf dependency-properties

我想创建一个Window,重新声明它自己的名为Content的DependencyProperty。

public partial class InfoWindow : Window
{
    public static new readonly DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(object), typeof(InfoWindow), new PropertyMetadata(null));
    public object Content
    {
        get { return GetValue(ContentProperty); }
        set { SetValue(ContentProperty, value); }
    }
}

XAML绑定此属性

<ContentControl Content="{Binding ElementName=_this, Path=Content}" />

它工作正常,只是Visual Studio Designer抱怨Logical tree depth exceeded while traversing the tree. This could indicate a cycle in the tree.

有没有办法告诉设计师绑定是InfoWindow.Content而不是Window.Content?或者隐藏属性是一个坏主意,我应该重命名我的属性吗?

0 个答案:

没有答案