Silverlight Close/Cancel button
- by Fizz
This is for Silverlight 4, I want to create a new button class for a close/cancel button to use on dataentry screens. The aim is to move the "confirm cancel" interaction to the control rather than having it in the ViewModel. Functional outline:
1) Have a property IsDirty, needs to support binding
2) Has two "states", controled by IsDirty
IsDirty = false - Content is "Close"
IsDirty = true - Content is "Cancel"
3) When clicked if it is Dirty show a message box to confirm cancel, before calling the command
4) Both states will call the command
Usage would be
<i:CancelButton Command="{Binding Path=CloseCommand}" IsDirty="{Binding Path=IsDirty}"/>
I am looking for pointers, I think a Templated Control would be the best option, but need some guidance on how to do this