【问题标题】:'Auto' value in binding property 'width'绑定属性“宽度”中的“自动”值
【发布时间】:2011-12-27 17:25:06
【问题描述】:

必须附加到属性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 中表示为 Auto0.5* 等的值。

有什么想法吗?

【问题讨论】:

    标签: wpf binding width


    【解决方案1】:

    您的TabPanelWidth 属性必须是GridLength 类型。使用GridLength,您可以使用GridUnitType 设置自动/星号大小。

    事实上,我想知道为什么绑定到 float 完全有效。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-01-18
        • 2011-05-08
        • 1970-01-01
        • 2011-11-29
        • 1970-01-01
        • 1970-01-01
        • 2011-08-26
        相关资源
        最近更新 更多