2011-11-12 32 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