Resizeable and Collapsable sidebar with GridSplitter
See original GitHub issueHi! I’m trying to make a resizeable and collapsable sidebar.
I expect it to have the following behaviour:
- A user can resize the sidebar up and down to a particular boundary (i.e. set Min and Max width).
- A user can entirely hide (and then show) the sidebar
I use Grid with three columns: one for the sidebar, the second for the GridSplitter to accomplish resize and the third for the main content.
If I configure the Grid like this:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
I can successfully resize the sidebar and hide it with IsVisible="True"
but it does not have Min Width. If I set MinWidth for the sidebar control
<Panel Grid.Column="0" MinWidth="100" />
I can still resize the leftmost column to the size less than it’s content MinWidth.
If I set MinWidth for a Grid Column:
<ColumnDefinition Width="Auto" MinWidth="100" />
The splitter lets me resize the column down to this MinWidth (just like I need), however, when I hide the sidebar with IsVisible="False"
the column persists (i.e. blank space with MinWidth is shown).
The splitter is very thin and it is not an option to resize the column to width 0 and consider this as “collapsed” since there is no way to resize it back.
I’m using Avalonia 0.10.0-rc1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
I solved that issue by applying one of two classes that change the
Grid.ColumnSpan
attribute and toggling visibility of GridSplitter and Sidebar container:SplitView has similar behavior out of box, but without grid splitter