XAML Multi-Level Binding Source/Path Issue
- by tpartee
So I have this issue I've been trying various ways to tackle all day and nothing's catching and working for it. Basically I have a XAML object called ChromeWindow (derived from Window) which has in it's code-behind a DependencyProperty called AppChrome which stores a reference to an associated ApplicationChrome XAML object (derived from UserControl). ApplicationChrome's XAML file has a few x:Name'd objects (a TextBlock and Border for instance) to which I want to bind to from the ChromeWindow's XAML. The root of the ChromeWindow is x:Name'd as 'rootWindow' in the XAML, so I figured one of these bindings would work:
{Binding ElementName=rootWindow, Path=AppChrome.CaptionTextBlock.Text, Mode=OneWay}
But that complains of a BindingExpression path error such that the property 'CaptionTextBlock' (an x:Name'd TextBlock in AppChrome's XAML) cannot be found on object of type ApplicationChrome
So I tried this binding intead:
{Binding Source=AppChrome.CaptionTextBlock, Path=Text, Mode=OneWay}
And still no luck, this time complaints of a BindingExpression path error again, but this time that it cannot find the 'CaptionTextBlock' property on object of type String
I know I'm missing something really simple here, please help! ;D