lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.67k stars 748 forks source link

Provides a way to remove the ScrollViewer from the NavigationView #1041

Open SlimeNull opened 7 months ago

SlimeNull commented 7 months ago

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

zbellerose commented 7 months ago

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

SlimeNull commented 7 months ago

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 ...

pomianowski commented 7 months ago

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

SlimeNull commented 7 months ago

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

andrewpros commented 4 months ago

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

View12138 commented 1 month ago

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