【发布时间】:2016-02-29 20:39:30
【问题描述】:
在我的用户控件(类LabeledBox)中,我添加了如下依赖属性。
public static readonly DependencyProperty HorizontalProperty
= DependencyProperty.Register(
"Horizontal",
typeof (Orientation),
typeof (LabeledBox),
new PropertyMetadata(default(Orientation)));
public Orientation Horizontal
{
get { return (Orientation) GetValue(HorizontalProperty); }
set { SetValue(HorizontalProperty, value); }
}
但是,根据以下设置时,不会给我任何行为差异。事实上,属性中的 setter 并没有被调用。我想念什么?
<local:LabeledBox x:Name="Info field"
Description="Info"
Horizontal="Horizontal" />
有问题的组件有一个堆栈面板作为最外层的控件,它的绑定是这样的。
<StackPanel Name="TheContainer" Orientation="{Binding Horizontal}">
也许我的绑定不正确?
【问题讨论】:
标签: c# wpf xaml binding user-controls