I am using MVVM architecture. I had created a user control which contains a button control.
I want the click event of the button control to be captured in page which uses this user control. How to do this? Plase help 🙂
I am using MVVM architecture. I had created a user control which contains a
Share
A button has a Command property. You should use that instead of the Click event by binding to an ICommand exposed by your ViewModel.
EDIT:
Two possibilities:
1) MVVM-way: Have a property for the command on your UserControl’s ViewModel which you then set from your using page’s ViewModel.
2) Non-MVVM way (although you could combine this with 1): Have a dependency property on your UserControl for the command, which you bind to in your UserControl’s XAML. You can then bind to this dependency property from the using page.