MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.08k stars 3.42k forks source link

ScrollViewer Padding #3570

Closed JorisCleVR closed 3 months ago

JorisCleVR commented 4 months ago

Is your feature request related to a problem? Please describe. Currently the padding of a ScrollViewer is ignored using ScrollViewerAssist.IgnorePadding. This is already great, because the padding otherwise would result in a too early cutoff on the content when scrolling.

Describe the solution you'd like I would like the padding to be applied again but then without the cutoff.

I figured out a possible way to resolve this that I currently apply in my own style, but it might be useful to apply this in the MaterialDesignInXamlToolkit itself. If so I would create a PR for this. Am curious about what you think about this solution.

The solution I currently use is setting the ContentTemplate and adding a ContentControl that applied the Padding.

    <Style TargetType="ScrollViewer" x:Key="DSScrollViewer" BasedOn="{StaticResource MaterialDesignScrollViewer}">
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="4" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="c:ScrollViewerAssist.PanningBasedOnScrollAvailability" Value="True" />
        <Setter Property="md:ScrollViewerAssist.IgnorePadding" Value="True" />
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentControl Margin="{Binding Padding, RelativeSource={RelativeSource AncestorType=ScrollViewer}}">
                        <ContentPresenter Content="{Binding}" />
                    </ContentControl>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
Keboo commented 4 months ago

Would be interested in seeing a PR, but looking at what is there now, I am a bit skeptical. Looking at the existing template it does appear to be used, and the style above looks like it would be dropping the base template.

https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/3aa4967d33ee442d91502dee04905b20d0acfc6d/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ScrollViewer.xaml#L90

Happy to take a look at a PR and discuss further though.

JorisCleVR commented 4 months ago

I create a PR for this issue: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/pull/3579 This also contains a more elaborate description about the old and the new situation.

nicolaihenriksen commented 3 months ago

@JorisCleVR I believe your PR fixing this was merged and included in the 5.1 release. If I am mistaken, feel free to re-open the issue.

JorisCleVR commented 3 months ago

It was indeed merged and included in 5.1