WPF Get ColumnSpan of an element
-
03-03-2021 - |
Question
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?
La solution
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.
Autres conseils
Besides of using GetValue(Grid.ColumnSpanProperty) as shown by sixlettervariables, you also can use Grid.GetColumnSpan().
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow