必须附加到属性宽度,我正在做什么:
<ColumnDefinition Width="{Binding Path=TabPanelWidth, RelativeSource={RelativeSource TemplatedParent}}" />
-
public float TabPanelWidth
{
get {return (float) GetValue (TabPanelWidthProperty);}
set {SetValue (TabPanelWidthProperty, value);}
}
public static readonly DependencyProperty TabPanelWidthProperty = DependencyProperty.Register ("TabPanelWidth", typeof (float), typeof (BivTabControl), new UIPropertyMetadata (null));
但我不仅需要设置固定值,还需要设置在 XAML 中表示为 Auto
、0.5*
等的值。
有什么想法吗?
最佳答案
您的 TabPanelWidth
属性必须为 GridLength
类型。使用GridLength
,您可以使用 GridUnitType
设置自动/星形大小.
事实上,我想知道为什么绑定(bind)到 float
有效。
关于wpf - 绑定(bind)属性中的“自动”值 'width',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8106333/