c# - WPF - How to set DataContext on virtual branch of logical tree? -


How do I set up DataContext of "myElement" in the same DataContext as user control in XAML? I am able to do this through code-back through the "code"> myElement.DataContext = this.DataContext , in the UserControl Constructor, but I am trying to understand that the only thing in XAML How to do.

This is related to creating virtual branches for logical tree (see this).

  & lt; UserControl ... DataContext = "{Binding Relative Soros = {Relative Asris}}" & gt; ... & lt; Text box name = "myTextBox" & gt; & Lt; TextBox.Text & gt; & Lt; Binding Path = "MySource" UpdateSourceTrigger = "Property Change" & gt; & Lt; Binding.ValidationRules & gt; & Lt; Base: StringEqualsRules & gt; & Lt; Base: StringEqualRule.BoundElement & gt; & Lt; Base: Validation RuleElement x: name = "myElement" DataContext = "???" Value = "{Binding MyProperty}" /> & Lt; / Base: StringEqualRule.BoundElement & gt; & Lt; / Base: StringEqualsRule & gt; & Lt; /Binding.ValidationRules> & Lt; / Binding & gt; & Lt; /TextBox.Text> & Lt; / Text box & gt; ... & lt; / UserControl & gt;  

Give an X to the top-level UserControl element: name then use an elementname binding Please. Like:

& Lt; / UserControl & gt;

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -