The ImageEx Control will Re-Animate from Placeholder to Loaded Image if located on a Page that calls Bindings.Update() to update any modified properties (Even if the properties of the control hasn't changed).
I think it also occurs with INotifyPropertyChanged, however, I'm not sure.
This is extremely annoying because it causes flickering of images during Background App processing.
@WilliamABradley could you please post a repro for this issue ?
UI
<Page
x:Class="Test.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:commtools="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<commtools:ImageEx x:Name="Test" Width="500" Height="500" PlaceholderSource="http://www.qsl.net/dl8ybm/pic/testbild4-3.png" Source="{x:Bind SourceImg, Mode=OneWay}"/>
</Grid>
</Page>
Code Behind
public sealed partial class MainPage : Page
{
Uri SourceImg { get; } = new Uri("http://pngimg.com/uploads/duck/duck_PNG4998.png");
public MainPage()
{
this.InitializeComponent();
TestIssue();
}
async void TestIssue()
{
await Task.Delay(TimeSpan.FromSeconds(2));
Bindings.Update();
await Task.Delay(TimeSpan.FromSeconds(2));
Bindings.Update();
await Task.Delay(TimeSpan.FromSeconds(2));
Bindings.Update();
await Task.Delay(TimeSpan.FromSeconds(2));
Bindings.Update();
await Task.Delay(TimeSpan.FromSeconds(2));
Bindings.Update();
}
}
just zip it and drop it here ?
It is so simple that it can be reproduced from just that code. Do I really have to submit a whole Solution?
Test.zip
Here it is anyway, beware it will only work properly on VS 17 because of Project.json migrated into to the csproj file.
I believe this behaviour is by design
https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-bind-markup-extension
Pages and user controls that include Compiled bindings will have a "Bindings" property in the generated code. This includes the following methods:
Update() - This will update the values of all compiled bindings. Any one-way/Two-Way bindings will have the listeners hooked up to detect changes.
Initialize() - If the bindings have not already been initialized, then it will call Update() to initialize the bindings
StopTracking() - This will unhook all listeners created for one-way and two-way bindings. They can be re-initialized using the Update() method.
@WilliamABradley whilst it might a small snippet, any one looking at this would have to find / create a repro. Attaching a repro is fastest way to reproduce an issue and I can attach correct projects to debug further.
Maybe the control should prevent re-animation if the value is the same when the bindings are updated, and the image is already loaded.
The Windows Image Control does not have this behaviour when Bindings are Updated, and I doubt that this is by design, because Bindings Update can be an important way to update the UI from after a background thread.
Edit: I have tested switching x:bind mode to OneTime, and the issue still occurs, so that confirms that this is not by design.
When I said by design I meant by design with regards to x:Bind behaviour. ImageEx does not have any source comparison at present and when Source update is triggered by Bindings.Update it just executes the full sequences.
Yes it can certainly be made better. I will keep this issue open. Feel free to push a PR with fix.
@WilliamABradley a check has been added. I validated the fix in sample app by calling Binding.Update on a Dispatcher Timer Tick event. You can test the fix out by pulling latest myget build.