bodong1987 / Avalonia.PropertyGrid

A property edit control in Avalonia like DevExpress's PropertyGridControl.
https://www.cnblogs.com/bodong
MIT License
184 stars 19 forks source link

Property's UI doesnt update when making changes to property in code #18

Closed artizzq closed 10 months ago

artizzq commented 11 months ago

I have one problem. For example, when I change property (e. g., DateTime) manually, by hand, and want to correct its value in code, I notice that visually nothing changes in control according to in-code changes. It shows not corrected value but the one I chose using picker and I notice corresponding changes only in code (variables). What possible reasons could be for it? I tried to define object as ReactiveObject and used "this.RaiseAndSetIfChanged" in set but no avail.

image image image

Is there any specific UI refresh command I missed?

bodong1987 commented 10 months ago

I have one problem. For example, when I change property (e. g., DateTime) manually, by hand, and want to correct its value in code, I notice that visually nothing changes in control according to in-code changes. It shows not corrected value but the one I chose using picker and I notice corresponding changes only in code (variables). What possible reasons could be for it? I tried to define object as ReactiveObject and used "this.RaiseAndSetIfChanged" in set but no avail.

image image image

Is there any specific UI refresh command I missed?

There is no interface to refresh the UI, everything is automatic. In theory, as long as the System.ComponentModel.INotifyPropertyChanged interface is implemented. There seems to be no problem with your operation. If the UI is not refreshed, there must be some special circumstances. Without the source code, it's difficult for me to determine the cause. If possible, it is recommended that you create a simple Avalonia Demo Project, then extract this small piece of code and add it, and then try to see if you can reproduce the problem. You can also send me this small DemoProject.

Or you can try to debug the source code directly. The relevant code is located at: DateTimeCellEditFactory.cs/HandlePropertyChanged

In addition, you can also confirm whether the RaiseAndSetIfChanged you called really takes effect, such as monitoring the PropertyChanged event of your own object.

bodong1987 commented 10 months ago

AvaloniaApplication23.zip check this demo.