【问题标题】:WPF Get ColumnSpan of an elementWPF获取元素的ColumnSpan
【发布时间】:2011-11-18 09:03:30
【问题描述】:

在网格中为 UIElement 设置列跨度非常容易。

Grid.SetColumnSpan(extBorder, gridFormular.ColumnDefinitions.Count());

但是关于读取元素的 ColumnSpan 是什么意思? 怎么做?

【问题讨论】:

    标签: wpf grid columnspan


    【解决方案1】:

    您可以在dependency property identifier for the column span 上使用FrameworkElement.GetValue

    var columnSpan = (int)extBorder.GetValue(Grid.ColumnSpanProperty);
    

    同样的策略适用于检索元素上存在的任何依赖属性的值。

    【讨论】:

    【解决方案2】:

    除了使用六字母变量所示的GetValue(Grid.ColumnSpanProperty),还可以使用Grid.GetColumnSpan()

    【讨论】:

    • +1,简单的答案。无论出于何种原因,我认为没有一个:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多