Hi,
I want to show some kind of a confirmation dialog whenever the user tries to save "TestObject" with "TestValue" over 5.
I have 2 problems in my attached sample:
1. If the last saved value is lower than 5,then I rerun the application, then change it to something above 5, I don't get a message. Only in the next time I'll get the message.
2. After the first time of getting the message, it will be there every time
Thanks
We have closed this ticket because another page addresses its subject:
How do I set the Action's confirmation message dynamically based on object property values before this action gets executed?problems during confirmation save
Answers
Hello Golan,
Here is a sample:
Code...
protected override void OnActivated() {
base.OnActivated();
controller = Frame.GetController<DetailViewController>();
((INotifyPropertyChanged)View.CurrentObject).PropertyChanged += new PropertyChangedEventHandler(CurrentObject_PropertyChanged);
}
private void CurrentObject_PropertyChanged(object sender, PropertyChangedEventArgs e) {
if(e.PropertyName == "TestEnum") {
controller.SaveAndCloseAction.ConfirmationMessage = message;
controller.SaveAction.ConfirmationMessage = message;
controller.SaveAndNewAction.ConfirmationMessage = message;
}
}
...
Thanks,
Constantine
Hello Golan,
Thank you for contacting us. We are working on your issue and will get back to you as soon as we can. We appreciate your patiance!
Thanks,
Dennis
Hello Golan,
Please pardon our delayed response.
Since you are checking object properties only on the ControlsCreated event, your code is called only once per view showing.
That's why you keep getting the same confirmation message even if the object was changed.
In your case, you need to correct the ConfirmationMessage dynamically every time a TestValue property value changed.
Feel free to contact us in case of further difficulties.
Thanks,
Constantine
Hi,
I slightly modified my project
You wrote:
"In your case, you need to correct the ConfirmationMessage dynamically every time a TestValue property value changed."
How do I know that it was changed and in which event should I check it?
In addition, I also have a enum property which is displayed as combobox. I want to find out whether the value in the combobox is different than the value that came from db.
This should be checked at the same situation as in my first question
Thanks
Hello Golan,
All BaseObject class descendants implement the INotifyPropertyChanged interface.
When a property value changes, the PropertyChanged event is raised.
You can handle the PropertyChanged event of the current object and correct the confirmation message depending on its property values.
Thanks,
Constantine
Hi,
I slightly modified my project according to your answer.
Still it doesn't work.
My application is xaf web application.
Thanks
Hi Golan,
Thank you for the update. Please let us some time to research your code. We will get back to you once we are done.
Thanks,
Dennis
Hello Golan,
First of all, you handle the Changed event instead of PropertyChanged. It will not work because in your case, this event is raised during the action execution when the confirmation message has been already checked.
Handle the PropertyChanded event instead, as I recommended before.
I have tested this approach with the latest version of the framework and can say that it works fine on my side.
However, there could be problems with previous versions since we have significantly improved the web part with the latest version.
I recommend you upgrade to the latest version to avoid such problems.
Thanks,
Constantine
Thank you,
Could you please send me an example that demonstrates the usage of PropertyChanged event in accordance with my case.
Thanks,
Golan