I want to bind the Enabled property of a Button on my C# Windows Forms application to whether an instance DataSet variable has changes. (I.e. if the DataSet is unchanged, disable the save button.)
The trouble is, DataSet.HasChanges is implemented as a method, not as a property, so it cannot be bound to. Is there any easy way to implement this? Am I approaching this the wrong way? It seems like something like this would be much easier than disabling and enabling the button manually wherever the data changes.
In my research I came up on this question, but its solution (designing classes such that what you need to bind to is a property) seems impractical for this situation.
In a WinForms application you don’t need to bind the Enabled property of the button directly to the DataSet at all. Build an intermediary layer (this will be easier to maintain and expand on later anyway), with a class that interprets the method of the DataSet into a Property that the control can bind to: