Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

How to bind to usercontrol child controls from parent view?

$
0
0
Hi!

I spent some time googling but so far no luck finding a good article, which is strange since thi´s should be a really common topic.

The situation is like this. In a current view+viewmodel there is a textbox in a grid column which is connected to a viewmodel property. Now they will rearrange things and this column now have to be two textboxes and a new property has appeared in the viewmodel. Currently they just do a simple binding in xaml to textbox.text={Binding Path=CurrentOrder.Order.ArticleNumber}

What I want to do is to write a usercontrol that has two textboxes that I somehow can bind to the viewmodel properties just like above. But I can't figure out how to do this binding in the xaml

The usercontrol will be used in many different views and the datacontext names may differ from place to place. So basically, what I really wanted is a way in xaml to write something like

<uc:myUserControl TextBox1Text={Binding Path=CurrentOrder.Order.ArticleNumber} TextBox2Text={CurrentArticle.Article.Unit} DividorCharacter={Binding Path=Common.DividorChar}</>

Is this the way to do it? The usercontrol doesn't have it's own viewmodel and should work like "plug and play", just connect textbox text properties to the properties in the viewmodel.

Also the character to show between textbox1 and 2 should be configurable also, how can I add this in xaml? This seems like really basic stuff, but maybe I google the wrong stuff?

/S

Viewing all articles
Browse latest Browse all 256

Trending Articles