简体   繁体   English

WPF获取元素的ColumnSpan

[英]WPF Get ColumnSpan of an element

It's really easy to set column span for an UIElement in a grid. 在网格中为UIElement设置列跨度非常容易。

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

but what's about reading an element's ColumnSpan? 但阅读元素的ColumnSpan是什么意思? How to do that? 怎么做?

You can use FrameworkElement.GetValue on the dependency property identifier for the column span : 您可以对列span依赖项属性标识符使用FrameworkElement.GetValue

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

This same strategy works for retrieving the value of any dependency property which exists on the element. 此相同策略适用于检索元素上存在的任何依赖项属性的值。

除了使用六个变量所示的GetValue(Grid.ColumnSpanProperty)之外,您还可以使用Grid.GetColumnSpan()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM