2011-11-12 36 views
1

值必须重视的属性Width,我在做什么的:“自动”在绑定属性“宽度”

 <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*等。

任何想法?

回答

1

您的TabPanelWidth属性必须为GridLength。使用GridLength,您可以使用GridUnitType设置自动/星号。

事实上,我不知道为什么绑定到float的作品。

0

使用相同的数据类型而不是float,它被称为GridLength