maui
maui copied to clipboard
Text property value does not change at runtime when using a style
Description
I have utilized a style for the label and bound its text property to a property in the ViewModel. Initially, I set the label's text value using the property in the ViewModel. Later, I changed its text property value by referencing it with a x:name in a button-clicked event. The text changed accordingly. and then, when I tried changing the binded property in the ViewModel using another button-clicked event, the text on the View did not update.
Steps to Reproduce
1.Click the changeBinding button. 2.click set selecteditem button
Observed behavior Label Text was not changed after clicking the set selected item button.
Expected behavior Label Text should be changed after clicking the set selected item button.
Link to public reproduction project repository
https://github.com/RiyashameedM/Label_Text_issue
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, Windows, macOS
Affected platform versions
all platforms
Did you find any workaround?
need to set binding for the label after the label.Text is updated.
Relevant log output
No response
Later, I changed its text property value by referencing it with a x:name in a button-clicked event.
AFAIK if you change the value manually that will remove the binding.
@RiyashameedM if you test this on NET7 does it work?
Hi @RiyashameedM. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Hi @PureWeen , Issue occurs only in .NET 8. When I use direct binding, such as Text="{Binding SelectedItem}", the value reflects both ways between label.Text = "" and viewmodel.SelectedItem, and it seems to be working fine. I could only reproduce the problem when binding values in styles. Is there any difference between style binding and direct binding?
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
the difference are the priorities Bindings from Style have a lower priority than direct binding or SetValue (the 2 having the same priority, so you can change one for the other)