asusralis
Topic Author
Posts: 119
Joined: 30 Jul 2018, 05:03

ProgressBar does not update correctly until hot reload.

25 Jun 2021, 18:57

<TextBlock Text="{Binding Relay.DaysUntilCompletion, StringFormat=Days Left: {0}}" />
<TextBlock Text="{Binding Relay.DaysPerDelivery, StringFormat=Days per delivery: {0:N1}}" />
<TextBlock>
	<Run Text="{Binding Relay.TotalDelivered, StringFormat=Amount Delivered: {0} /}" /> <Run Text="{Binding Relay.CurrentOrder.Amount}" />
</TextBlock>
<ProgressBar
	Height="20"
	Margin="0,5"
	Maximum="{Binding Relay.Distance}"
	Minimum="0"
	Value="{Binding Relay.Timer}" />
    public class RelayVM : VM
    {
        public TransportRelay Relay { get; }

        public RelayVM(TransportRelay relay)
        {
            Relay = relay;
        }
    }
When the progress bar was directly binding with the Relay object, its values updated correctly. However, when I created a VM and binded to the object via the Relay property, the progress bar does not update. Only after I do a hot reload of any kind does the progress bar start to update. Removed some VM code for visibility.

Note that other controls are binding to properties in Relay and are updating correctly without needing a hot reload. Also, once a hot reload is complete the Timer & Distance properties update when they should (not just once) so they do implement property changed correctly.

Video: https://files.catbox.moe/tieful.mp4
 
User avatar
sfernandez
Site Admin
Posts: 2255
Joined: 22 Dec 2011, 19:20

Re: ProgressBar does not update correctly until hot reload.

28 Jun 2021, 11:42

Is it possible that Distance does not notify the property change? The only thing I can think of is that initially it has a value of 0, the datacontext is set, and later Distance property is updated but not notified to the UI. It will work when doing the hot-reload because then the Relay object already has the Distance property correctly set.

I tried to reproduce your scenario but it works for me, even if I set the Distance property later.
 
asusralis
Topic Author
Posts: 119
Joined: 30 Jul 2018, 05:03

Re: ProgressBar does not update correctly until hot reload.

30 Jun 2021, 17:06

But from the video, the Distance property updates every time the date changes - not just initially after the hot reload. The Distance property implements the property change like all other properties in my project. If I bind the Distance to a TextBox's Text, the text updates correctly without having to hot reload.

I don't need this progress bar anymore, so it isn't an issue for me... It seems other progress bars work in my project. I am free to send you the project if you want, or if you think it was on my end that's fine too and I can mark this as solved : )
 
User avatar
sfernandez
Site Admin
Posts: 2255
Joined: 22 Dec 2011, 19:20

Re: ProgressBar does not update correctly until hot reload.

01 Jul 2021, 10:22

From the xaml I assumed the Distance property was set only once (as it is the Maximum of the progress bar), and the Timer property (bound to progress bar's Value) was the one changing.

If you can provide a way to reproduce this I can take a look to see if there is something wrong on our side.

Who is online

Users browsing this forum: Bing [Bot] and 2 guests