c# - Setting ViewModel's Property from XAML -


i have usercontrol, it's datacontext binded viewmodel, how set viewmodel's property xaml? possible?

upd : sorry being not clear, i'm trying : usercontrol's datacontext binded viewmodel, need set viewmodel's property (let's say, usercontrol's width property). possible?

upd2: seems not possible.i know twoway binding mode, etc, thing wanted - set viewmodel's property usercontrol's one

this example should clear

<set property={binding somepropertyonviewmodel}       value={binding relativesource={relativesource self},                      path=somepropertyonusercontrol}> 

binding works both ways: i.e. source (e.g. viewmodel) target (e.g. usercontrol) , target source.
specify direction via mode of binding.

following bindingmodes:

  • twoway
  • oneway
  • onetime
  • onewaytosource

in case, if want bind width property of usercontrol thewidth property of viewmodel:

case a:
want bind in both directions, use mode=twoway

<usercontrol width="{binding thewidth, mode=twoway}"> <!-- rest of code --> </usercontrol> 

case b:
want bind usercontrol viewmodel, use mode=onewaytosource

<usercontrol width="{binding thewidth, mode=onewaytosource}"> <!-- rest of code --> </usercontrol> 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -