Wpf controls overlay?
-
25-02-2021 - |
Question
I have Dockpanel on which there are two buttons (left and right sides) and a scrollviewer at the bottom. Is it possible to hide the left and right sides of this scrollviewer UNDER this buttons?
Solution
You could use a Grid
instead of a DockPanel
, either use the alignments or create columns and adjust the ColumnSpan
, example of the latter:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Order matters, earlier controls are at the bottom unless you use Panel.ZIndex -->
<ScrollViewer Grid.Column="0" Grid.ColumnSpan="3"/>
<Button Grid.Column="0" Content="Left"/>
<Button Grid.Column="2" Content="Right"/>
</Grid>
(DockPanel is quite a poor control which can easily be replaced with a Grid in about every case)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow