Reputation: 160
I'm creating a resource in the window xaml. That resource is a controller, like this
<Window.Resources>
<ext:Controller x:Key="Controller"/>
</Window.Resource>
I have controls in my xaml that I want to bind to "compund members" in the Controller, so to speak. Like if I hade a string in the controller and I want to bind to that strings length
<TextBlock Text="{Binding Source={StaticResource Controller},Path=myString.Length}"/>
or something like that.
It seems like a weird way to do it but I want to keep all of those members in the controller as opposed to making them separate resources, so they have access to certain things in the controller.
The real essence of the problem is that I have a couple of Windows and I want them to share the common resource (an instance of Controller). So i put a static instnace of controller in controller. i actually want to bind like
<TextBlock Text="{Binding Source={StaticResource Controller},Path=StaticInstance.memberProperty/>
Is it possible to bind to a member of a member or what approach should I be using instead of wanting the "compound path in the binding", so to speak?
Thanks, guys! Appreciate the help
Upvotes: 0
Views: 279
Reputation: 184516
StaticInstance
is not a property of your resource (which is an instance) since it is static. If you want to bind to static members you can use the x:Static
markup extension, note that the syntax is quite specific.
The binding probably would look like this:
{Binding Source={x:Static myns:Controller.StaticInstance}, Path=memberProperty}
Upvotes: 3