The problem you are experiencing usually occurs if another procedure accidentally resets the EntryPlaceholderText property after the command completes, or there is an unstable binding.
Here are some possible causes:
1. Bindings are overwritten or reset elsewhere
Make sure no other bindings or code changes the EntryPlaceholderText after the command is executed.
2. Properties are not set consistently
When EntryPlaceholderText is changed within a command, make sure that there is no other code that frequently has that value.
3. UI doesn't refresh because binding is incorrect
Even though you've called OnPropertyChanged(), it could be that the binding in the UI is not active or doesn't respond to changes.
4. UI changes can be due to Load or BindingReset
If the page or view is re-navigated or refreshed, it can cause properties to return to their initial values.
5. Check the type and binding context
Make sure x:DataType="local:ExampleViewModel" and its binding are correct.
Make sure the Placeholder Property Entry is actually bound to EntryPlaceholderText and that there are no other bindings.
Solutions you can try:
- Add Debug.WriteLine() to the property set and OnPropertyChanged() to make sure when and where the property changes and resets.
- Make sure there is no other logic that changes the EntryPlaceholderText.
- Try setting the EntryPlaceholderText value in the constructor as well to a default static, then change it on click.
Conclusion:
Essentially, when the button is pressed, the value of EntryPlaceholderText changes and the UI displays that change, but then something resets the value. Usually this is because:
1. There is some other logic that changes it,
2. Binding error; or
3. The page is reloaded so the default values are loaded again.
Double check all parts that manipulate this property, and make sure no other code changes it after the command completes.