wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

Provides a way to remove the ScrollViewer from the NavigationView

Open SlimeNull opened this issue 10 months ago • 6 comments

Describe the bug

In my page, there is an area, its height is adaptive, and the content is with ScrollViewer, as long as the page is limited to the frame of the NavigationView, instead of being free to get bigger, this set of layouts works, however, because NavigationView has a built-in ScrollViewer, this causes the height of my Page to no longer be limited, but to become very high, So my whole page became scrollable, but in my expectation, the only area that could be scrolled was a part of the ScrollViewer that I put in

To Reproduce

  1. Add a NavigationView to the main window.
  2. Navigate to a page with a ScrollViewer, and the ScrollViewer cannot be forced to limit height.

The layout of the page can look like this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition MinHeight="200"/>
        <RowDefinition Height="3"/>
        <RowDefinition Height="120" MinHeight="60" MaxHeight="500"/>
    </Grid.RowDefinitions>

    <ScrollViewer Grid.Row="0">
        <ItemsControl ItemsSource="{Binding ViewModel.Messages}"/>
        <!-- When there are more messages, this should become a scrollable area -->
    </ScrollViewer>

    <GridSplitter Grid.Row="1" 
                  VerticalAlignment="Stretch" 
                  HorizontalAlignment="Stretch"/>

    <Grid>
        <TextBox />
        <Button Margin="12" 
                Content="Add message"
                Command="{Binding AddMessageCommand}"
                VerticalAlignment="Bottom" 
                HorizontalAlignment="Right" />
    </Grid>
</Grid>

Expected behavior

Allows the user to remove the ScrollViewer from the NavigationView so that the Page is non-scrollable

Screenshots

The messages area should be scrollable. image

However, the message area does not appear as a scroll bar, and the entire page becomes scrollable image

OS version

Windows 11 23H2 (22631.3296)

.NET version

8.0.203

WPF-UI NuGet version

3.0.3

Additional context

No response

SlimeNull avatar Apr 08 '24 07:04 SlimeNull

This is needed if it isn't already implemented. If someone has a workaround please let me know.

zbellerose avatar Apr 11 '24 19:04 zbellerose

This is needed if it isn't already implemented. If someone has a workaround please let me know.

I'm now using version 2.1.0 of the WPF-UI package, and even though it's already marked as "deprecated", because the different parts of its NavigationView control are separated, I can just use its "NavigationStore" and then place the Frame control myself.

This solved my problem for the time being ...

SlimeNull avatar Apr 14 '24 10:04 SlimeNull

It's not the NavigationView that has ScrollViewer, but a Page. Take a look at https://github.com/lepoco/wpfui/blob/main/src/Wpf.Ui.Gallery/Views/Pages/DesignGuidance/IconsPage.xaml

https://github.com/lepoco/wpfui/blob/303f0aefcd59a142bc681415dc4360a34a15f33d/src/Wpf.Ui.Gallery/Views/Pages/DesignGuidance/IconsPage.xaml#L20

pomianowski avatar Apr 14 '24 10:04 pomianowski

But, the default value of ScrollViewer.CanContentScroll seems to be "False", why the page become scrollable?

Here is the defination of ScrollViewer.CanContentScrollProperty: ScrollViewer - source.dot.net

SlimeNull avatar Apr 14 '24 11:04 SlimeNull

Well i dont know why, i had the same issue, but setting ScrollViewer.CanContentScroll to False on the Page do work.

andrewpros avatar Jun 21 '24 20:06 andrewpros

I also think that Should be provided IsDynamicScrollViewerEnabled property in the NavigationView, in order to control whether to use DynamicScrollViewer in NavigationViewContentPresenter

View12138 avatar Sep 20 '24 02:09 View12138