I'm looking for a best practise in the following scenario. This scenario has been made up just to illustrate the problem in a simplified manner.
Assuming we have the following Layout, to store an address.
Though some customers might think, the e-mail is more important than the name, and hence would like to display it before the name. Some customers might need more space for the name. Some customers cry because they don't need any phone numbers at all.
My goal: The user should be able to decide, how his form looks like.
I would like to set up a default template which should work for most customers.
I prefer not to reinvent the wheel, so is there any library which provides such functionality?
Such functionality could be (at runtime):
- Reorder Controls (e.g. with drag and drop)
- Store and Load UI Layout Templates
- Set Controls Visible / Invisible
- Resize Controls
If not, what would be the "best practise" to solve this?
If I had to reinvent the wheel, the most probable solution would be to create my own XML, which I would load at runtime and then set the rows and columns. But since I'm quite new to WPF, I don't know if this was a proper solution.
At last, below is the XAML of the above example:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Name:"/>
<Label Grid.Row="1" Grid.Column="0" Content="E-Mail:"/>
<Label Grid.Row="2" Grid.Column="0" Content="Phone:"/>
<Label Grid.Row="3" Grid.Column="0" Content="Address:"/>
<TextBox Grid.Column="1" Grid.Row="0" Margin="3" />
<TextBox Grid.Column="1" Grid.Row="1" Margin="3" />
<TextBox Grid.Column="1" Grid.Row="2" Margin="3" />
<TextBox Grid.Column="1" Grid.Row="3" Margin="3" />
<Button Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" MinWidth="80" Margin="3" Content="OK" Click="Button_Click" />
</Grid>