I have several controls which I would like to all share the same width, specified at compile time. So either they all use a width of 10, all use a width of 20, etc.
What is the proper way to define this value once, and use it like a variable from there on out?
“Gives you the idea” pseudocode:
double my_width = 10;
<Label width=my_width content="some text"/>
<Label width=my_width content="some text"/>
<Label width=my_width content="some text"/>
<Label width=my_width content="some text"/>
Here is a nice little trick I have seen
In addition to solving the problem, this lets you separate the width setting from other Style properies you might want to apply (to different label widths). As an added bonus, the GridLength structure supports “*” and “Auto” property for when you want to actually use it for a grid.
Cheers,
Berryl