CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.38k forks source link

RotatorTile+ImageEx - strange behavour #751

Closed bondarenkod closed 7 years ago

bondarenkod commented 7 years ago

I found issue with RotatorTile and ImageEx on stable and dev builds. There is no issues with default image control.

Here is video (click to view): video

Here is XAML code as text: Here is sample project as zip and github

hermitdave commented 7 years ago

Thanks for the repro.. Will check

bondarenkod commented 7 years ago

@hermitdave I forgot one small thing: there is no issues with default image control. Thank you!

hermitdave commented 7 years ago

Yes i can imagine.. I presume somewhere source It's being set again.. ImageEx doesn't check existing source with what's coming.. Hence reload

hermitdave commented 7 years ago

found this to be the cause

sb.Completed += (a, b) =>
{
    // Reset back and swap images, getting the next image ready
    sb.Stop();
    if (_translate != null)
    {
        _translate.X = _translate.Y = 0;
    }

    if (_currentElement != null)
    {
        _currentElement.DataContext = _nextElement.DataContext;
    }

    if (_nextElement != null)
    {
        _nextElement.DataContext = GetNext(); // Preload the next tile
    }
};

The _nextElement.DataContext being set causes image to be loaded first time.. then as the item moves into position, _currentElement.DataContext being set causes the image to be reloaded

hermitdave commented 7 years ago

thinking out loud here and probably very wrong in the tought.. but why not use FlipView as an underlying control to RotatorTile.. @deltakosh any thoughts.. sorry disturbing your holiday

deltakosh commented 7 years ago

Ping @dotMorten

dotMorten commented 7 years ago

The rotator works by having two areas: Current and next. When it rotates, it sets 2nd area to the new image first, then translates over to the 2nd area. Once complete, it also sets the 1st area to the new image, then resets the translation. So what you're seeing is the reset. Generally this should happen instantly and you wouldn't really see the flip.

Now I'm guessing you have some kind of load animation on the image. Probably the use of controls:ImageEx is really causing this, and you should be using a control that doesn't animate in. (I can't remember if we have a setting for turning off the animation, but if not perhaps we should add that)

I would say this issue is by design / known limitation