René Stalder
René Stalder

Reputation: 2546

WPF Get ColumnSpan of an element

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?

Upvotes: 3

Views: 1271

Answers (2)

HCL
HCL

Reputation: 36775

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

Upvotes: 5

user7116
user7116

Reputation: 64068

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.

Upvotes: 6

Related Questions