wpf - How to Bind to a Child's Background in Xaml? -


i'm able bind child's background if child explicitly named in elementname:

<treeviewitem header="test" background="{binding elementname=testchild, path=background}">    <textbox name="testchild" text="hello?" background="{binding somebinding}" /> </treeviewitem> 

i'd prefer use relative position rather specific names. possible bind child using relative? in case first child. following doesn't work seems should.

<treeviewitem header="test" background="{binding relativesource={relativesource mode=self}, path=children[0].background}"> 

unless create new control inherits treeview (or other itemscontrol) wont work. reasoning way binding works. when binding set children[0] doesn't exist collection empty. after collection updated include textbox , doesn't raise notify has changed (its not observablecollection). way create new control has children observablecollection. fwiw dont think worth hassle , better off using elementname.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -