Laden...

ScrollViewer - Scroll parent ScrollViewer wenn am Anschlag

Erstellt von ByteDevil vor 4 Jahren Letzter Beitrag vor 4 Jahren 804 Views
ByteDevil Themenstarter:in
132 Beiträge seit 2013
vor 4 Jahren
ScrollViewer - Scroll parent ScrollViewer wenn am Anschlag

Hi,

ich habe zwei ineinander verschachtelte ScrollViewer. Wenn ich mit der Maus über dem inneren bin, scrolle ich den vertikal hoch und runter mit dem Mausrad...alles gut. Bin ich ausserhalb, aber immer noch im äußeren, scrolle ich den äusseren. Auch alles prima so. Bin ich nun aber im inneren und habe beispielsweise nach ganz oben gescrollt, wäre es schön wenn der äussere dann das Scroll-Event kriegt und dann nach oben Scrollt. Analog natürlich auch abwärts. Dachte irgendwie das wäre das Standardverhalten von WPF aber anscheinend habe ich mich getäuscht. Gibt es einen einfachen Weg das zu erreichen?

Grüße

EDIT: In diesem Post ist ein gif zu sehen in dem das gezeigt ist was ich will. Auch wenn das dort als Bug bezeichnet wird.

EDIT: Minimalbeispiel:

<ScrollViewer VerticalScrollBarVisibility="Auto">
            <Grid Width="400" Height="600">
                <ScrollViewer>
                    <StackPanel Width="200">
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                        <TextBlock Text="1234"/>
                    </StackPanel>
                </ScrollViewer>
            </Grid>
        </ScrollViewer>
ByteDevil Themenstarter:in
132 Beiträge seit 2013
vor 4 Jahren

In the category of the pot talking to the pan, I present you ScrollViewer. It's the main control to implement scrolling in your templates, but it's also the one not respecting a very fundamental rule of scrolling: if you're done scrolling, let your parent scroll!

Not only does ScrollViewer handles the mouse scrolling even when no more scrolling is needed, but it also does so when there's nothing to scroll, or worse when it is told not to scroll!

Das scheint ein komplizierteres Problem zu sein. Habe hier was dazu gefunden, allerdings klappt das nur, solange in den ScrollViewern nur controls sind die von UIElement erben. Habe bei mir noch irgendwo anscheinend einen Document.Run drin, dabei crashed es dann. Verhindere ich das mit einer prüfung auf null, funktioniert es manchmal und manchmal nicht...

Bin sehr verzweifelt...