sbaeumlisberger / VirtualizingWrapPanel

Implementation of a comprehensive VirtualisingWrapPanel for WPF
MIT License
242 stars 33 forks source link

MakeVisible behaviour failing when there is a rendertransform on hover #47

Closed DSPaul closed 10 months ago

DSPaul commented 10 months ago

I have a GridView to which I have added a little hover effect that makes the items grow a little as shown here:

<wpftk:GridView ItemsSource="{Binding Items}">
    <wpftk:GridView.ItemContainerStyle>
        <Style TargetType="{x:Type ListBoxItem}">
            <Setter Property="RenderTransformOrigin" Value="0.5, 0.5"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="RenderTransform">
                        <Setter.Value>
                            <TransformGroup>
                                <ScaleTransform ScaleY="1.1" ScaleX="1.1"/>
                            </TransformGroup>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </wpftk:GridView.ItemContainerStyle>
    <wpftk:GridView.ItemTemplate>
        <DataTemplate>
            <Border>
                ...
            </Border>
        </DataTemplate>
    </wpftk:GridView.ItemTemplate>
</wpftk:GridView>

This works as expected but has a very bizar side effect. The BringIntoView functionality inherited from Listbox breaks completely. When you scroll down a bit and then click on an item, the Gridview will scroll way down. If I set the scale of the transform to 0.9, it will scroll way up, setting the scale back to 1 makes it behave as expected.

I have tried replacing the Gridview for a normal ListView with a wrapPanel as a, itemsTemplate to double check that it's not a WPF problem but that works fine so I am inclined to believe the problem lies with the GridView. I have made a mini repo that showcases the bug: https://github.com/DSPaul/BringIntoViewBug. All you have to do is scroll down around half way and select an item.

I have already found an easy workaround: I simply moved to style with the trigger and transfrom to the border in the itemTemplate which does the trick. Despite it not really being an issue for me, it still wanted to document it so you are aware and can investigate it if you want.

Version Info Package Version 1.5.7 .NET Version: 7.0 OS Version: Windows 10 Build 19045.3570

sbaeumlisberger commented 10 months ago

Thanks for the report and repo. I will have a look at it.

sbaeumlisberger commented 10 months ago

new version with a fix is published to nuget: https://www.nuget.org/packages/VirtualizingWrapPanel/1.5.8