PersuitOfPerfection
PersuitOfPerfection

Reputation: 1029

User theming (control positioning) in win forms

I'm looking to allow users to position existing controls via a theme file.

For instance, imagine if there was a text box at the top middle, a picture bottom left and a button at the bottom right.

The user would be able to specify the positions of the elements via a theme file.

I'm not asking how to create a theme file. My intent is to gather if this is possible first using win forms and how others go about it.

I know that it's possible using WPF and xaml, but I'd prefer to use win forms and I'm hoping someone can point me in the right direction.

Thank you

Upvotes: 0

Views: 34

Answers (1)

Dennis
Dennis

Reputation: 37780

Comparing to XAML UI like WPF, which is layout-based, WinForms is coordinate-based framework, so, if you load control's location from somewhere, you can easily apply it. Something like this:

var userNameTextBox.Location = myThemeService.LoadLocation(userNameTextBox.Name);

Note, that Location is relative to control's container.
You have to consider this when setting coordinates in your theme.

Upvotes: 2

Related Questions