locked
Bind Command in Dependency Property defined from UserControl RRS feed

  • Question

  • Hi, please help me in the following requirements:

    I have user control that contains a method (eg. change grid background). This method has to be triggered by the button which is in the View and its command is defined from ViewModel. Question: How to bind the command defined from ViewModel to Dependency property defined in code behind of user control?

    Thanks,

    Jaypee

    Tuesday, April 14, 2015 2:38 AM

Answers

  • Hi Jaypee,

    As I understand from your question looks like you want to find a control from your ViewModel, then you can change the dependency property of that control.

    You can consider about passing the View as an object to the viewModel as this discussion mentioned: http://stackoverflow.com/questions/14236222/how-can-i-access-a-control-in-mvvm-model-in-viewmodel, even its talk about WPF, but I have tested with Windows Store App. Should work.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 15, 2015 6:41 AM
    Moderator