I am having ListView control which has button collections inside itemtemplate and want to handle the enable and disable of each button on ViewModel.
I am having ListView control which has button collections inside itemtemplate and want to
Share
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.
My best advice would be: use a command (I usually use Prism’s
DelegateCommandorDelegateCommand<T>, you can download Prism package via NuGet which makes it literally painless).You then bind your button’s command to the command:
The
CanExecutemethod of the command will determine if the button is to be enabled or disabled.Another approach is expose an
IsEnabledproperty in your ItemViewModel, then bind the IsEnabled property on the button to it.If you need to bind to a property in the parent ViewModel, you could get to it from the template in several approaches.
Here are some: