Grid grows when content grows, but does not shrink when content shrinks.
I have a ScrollViewer ControlTemplate that looks like this (simplified for readability):
The ScrollViewer is used inside a ListView/GridView, and PART_ScrollContentPresenter displays the columns. If PART_ScrollContentPresenter grows (e.g. show hidden column), the Grid grows with it, so everything is displayed correctly. However if PART_ScrollContentPresenter shrinks, the Grid stays the same size, leaving a gap between PART_ScrollContentPresenter and PART_VerticalScrollbar.
How can I get the Grid to properly follow the size of its contents?
Code: Select all
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
<DockPanel>
<ScrollViewer>
<GridViewHeaderRowPresenter />
</ScrollViewer>
<ScrollContentPresenter
Name="PART_ScrollContentPresenter"
/>
</DockPanel>
<ScrollBar
Name="PART_VerticalScrollBar"
HorizontalAlignment="Right"
/>
</Grid>
</ControlTemplate>
How can I get the Grid to properly follow the size of its contents?
- KeldorKatarn
- Posts: 193
- Joined:
Re: Grid grows when content grows, but does not shrink when content shrinks.
Why is there a scrollviewer inside your scrollviewer template?
-
sfernandez
Site Admin
- Posts: 2983
- Joined:
Re: Grid grows when content grows, but does not shrink when content shrinks.
Hi peter, could you please report this in our bugtracker. I'm seeing this behavior also in our default template for the ListView so there must be a bug.
This is the template for the scrollviewer used in the ListView, and the inner ScrollViewer is to allow horizontal scrolling in the column headers as they are not part of the item rows.Why is there a scrollviewer inside your scrollviewer template?
Who is online
Users browsing this forum: Google [Bot] and 74 guests