Hi
i have a configuration class, that is meant to configure a complex ribbon bar class.
The configuration class has a collection of ConfigurationItems and the
ConfigurationItem derives from DependencyObject and has some dependency properties.
You can create this class (and the configuration class) in XAML and set its properties,
but the configuration has no UI itself and is not visual.
I defined a binding in XAML:
<TabConfigurationItem Active="{Binding Path=IsAdminUser}" Key="..." />
where "Active" is the dependency property and "IsAdminUser" is a boolean Property
of the DataContext / ViewModel and TabConfigurationItem is derived ConfigurationItem.
When I load the UI I get
"System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element...DataItem=null..."
I checked the params and noticed that when the error is raised, the DataContext exists
And it exposes the said "IsAdminUser" property. So it should work at first glance.
Also i tried some binding variations (using ElementName or RelativeSource)
but no sucecss.
Now I begin to think that the reason for th error is that one cannot really bind
dependency properties of non visuals that way, because they are not
part of the visual tree and they have no DataContext (DataContext comes with FrameworkElement)
So they don't "see" the parent DataContext, so that's why there is "no governing FrameworkElement" ?!?
If this is true, how can I bind such a Dependency property of a non-visual DependencyObject
to something in my ViewModel that is not static? (Not a StaticResource nor x:Static)?
Thanks,
Chris