maui icon indicating copy to clipboard operation
maui copied to clipboard

Text property value does not change at runtime when using a style

Open RiyashameedM opened this issue 1 year ago • 4 comments

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

RiyashameedM avatar Jan 09 '24 05:01 RiyashameedM

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?

PureWeen avatar Jan 09 '24 19:01 PureWeen

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.

ghost avatar Jan 09 '24 19:01 ghost

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?

RiyashameedM avatar Jan 10 '24 05:01 RiyashameedM

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.

ghost avatar Jan 11 '24 19:01 ghost

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)

StephaneDelcroix avatar Feb 20 '24 15:02 StephaneDelcroix