在我的应用程序中,我创建了模板控件。现在我想将 MinWidth 绑定到依赖属性。例如在我的 xaml 我有
<ColumnDefinition Width="Auto" MinWidth="{TemplateBinding ColumnWidth}"/>
在我的代码中
public double ColumnWidth
{
get { return (double)GetValue(ColumnWidthProperty); }
set { SetValue(ColumnWidthProperty, value); }
}
public static readonly DependencyProperty ColumnWidthProperty =
DependencyProperty.Register(
"ColumnWidth", typeof(double), typeof(Schedule), new PropertyMetadata(200));
不幸的是,它不起作用,我不知道为什么。MinWidth 始终为 0。也许有人知道我做错了什么?