我想创建一个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
?或者隐藏属性是一个坏主意,我应该重命名我的属性吗?