Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrange error when item keep aspect ratio. #36

Closed
CodingOctocat opened this issue Mar 16, 2022 · 3 comments
Closed

Arrange error when item keep aspect ratio. #36

CodingOctocat opened this issue Mar 16, 2022 · 3 comments

Comments

@CodingOctocat
Copy link

CodingOctocat commented Mar 16, 2022

I'm developing an image gallery that can be previewed by thumbnails just like Explorer.

<wpftk:VirtualizingItemsControl
    Margin="0,2,0,0"
    ItemTemplate="{StaticResource ItemTemplate}"
    VirtualizingPanel.CacheLengthUnit="Item"
    VirtualizingPanel.CacheLength="1,1"
    VirtualizingPanel.ScrollUnit="Pixel"
    VirtualizingPanel.VirtualizationMode="Standard"
    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
    ScrollViewer.VerticalScrollBarVisibility="Auto">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <wpftk:VirtualizingWrapPanel
                Orientation="Vertical"
                SpacingMode="None" 
                StretchItems="True">
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</wpftk:VirtualizingItemsControl>

ItemTemplate:

<DataTemplate x:key="ItemTemplate">
    <mycontrol:MyThumbnail ImageSource="xxx/yyy/zzz.jpg"/>
</DataTemplate>

Bind the Height of the MyThumbnail control to the Width so that it always remains 16:9.
And Arrange error(I will re-upload screenshots of the real situation when I have time):
微信截图_20220316085741

I guess the reason lies in the dynamically changing height of the item.

I have tried the following solution and it works fine (but it not support virtualization):
WrapPanel with full width columns
UniformMinWidthWrapPanel

Version Info
Package Version 1.5.7
.NET Version: .NET 6
OS Version: Win11

@CodingOctocat
Copy link
Author

Actual results:
Snipaste_2022-03-16_18-10-50
Snipaste_2022-03-16_18-10-41

@CodingOctocat
Copy link
Author

CodingOctocat commented Mar 16, 2022

When I drag the scrollbar:
It gets worse!
Snipaste_2022-03-16_18-59-04

@sbaeumlisberger
Copy link
Owner

sbaeumlisberger commented Mar 26, 2022

Hi, in order to support virtualization the panel currently requires all items to have the same size. There is already an issue with the aim to allow different sized items: #22 Unfortunately, I don't have time to work on it actively at the moment. Hopefully, this will change in the summer.

In order to solve your issue right now you have to make sure that all items are sized equally. Therefore you can use the ItemSize property or set some size constraints on item template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants