Could you please suggest an elegant way to check if a data on the view has been modified to enable the Save button accordingly?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you are using MVVM with Caliburn.micro, there is a Can-convention for commands. So, assuming you want to enable Save button if a string property named Username is non-empty, you simply add this method to the viewmodel:
Assuming your class inherits PropertyChangedBase or Screen, and you have a button with Name=”Save”, it will be disabled if UserName is empty. If you are interested in data changing in the view, the relevant property, in this example UserName, would of course have to be bound to some input area in the view – you could for instance have a TextBox named UserName which would make Caliburn set up the binding by convention.
The class in its entirety would then look something like this:
Edited to only allow saving of actually different data