WPF / Silverlight Build Best Practices

What would be the best practice for laying the next item?

Valid XHTML http://www.hughgrice.com/layout.gif .

I am particularly interested in what controls should I use, and how do I put the delete icon on the right side, and the tool icon always appears in the middle?

Thanks in advance.

+4
source share
3 answers

My preferred panel for this case is the DockPanel, not the grid:

<DockPanel> <Button>Add</Button> <Label>This is a label</Label> <Button DockPanel.Dock="Right">Del</Button> <Button HorizontalAlignment="Center">Setting</Button> </DockPanel> 
+5
source

How about this:

 <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Image Source="Plusbutton" /> <Label Text="This is a Label" Margin="3,0,3,0" Grid.Column="1" /> <Image Source="Gear" HorizontalAlignment="Center" Grid.Column="2" /> <Image Source="Minusbutton" Margin ="3,0,3,0" Grid.Column="3" /> </Grid> 
+3
source

Grid is good for this: -

 <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <StackPanel HorizontalAlignment="Left" Grid.Column="0"> <!-- Your content here --> </StackPanel> <StackPanel HorizontalAlignment="Center" Grid.Column="1"> <!-- Your content here --> </StackPanel> <StackPanel HorizontalAlignment="Right" Grid.Column="2"> <!-- Your content here --> </StackPanel> </Grid> 

This approach separates the main Grid of Left, Center, and Right content from the content itself. In your example, the Left StackPanel will have two elements. The contents of each panel should only be associated with its layout compared to other sister items in the panel.

+3
source

Source: https://habr.com/ru/post/1301964/


All Articles