3

It's really easy to set column span for an UIElement in a grid.

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

but what's about reading an element's ColumnSpan? How to do that?

René Stalder
  • 2,536
  • 5
  • 31
  • 50

2 Answers2

6

You can use FrameworkElement.GetValue on the dependency property identifier for the column span:

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

This same strategy works for retrieving the value of any dependency property which exists on the element.

user7116
  • 63,008
  • 17
  • 141
  • 172
5

Besides of using GetValue(Grid.ColumnSpanProperty) as shown by sixlettervariables, you also can use Grid.GetColumnSpan().

HCL
  • 36,053
  • 27
  • 163
  • 213