EDIT: I rephrased the entire question.
Hello everybody,
I have a custom control with dependency properties. In the Generic.xaml file I have a resource dictionary. It's a resource dictionary within the outer dictionary, defined like so:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyNamespace">
<!-- This is the dictionary-->
<ResourceDictionary x:Name="TheDictionaryImTalkingAbout" . . . >
.
.
.
</ResourceDictionary>
.
.
.
</ResourceDictionary>
In this resource dictionary, TheDictionaryImTalkingAbout, I want to bind to a dependency property of my control. I tried the following XAML :
<Object x:Key="MyObject" SomeProperty="{Binding MyDependencyProperty, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MyNamespace:MyControl}}}"/>
The binding returns no errors, however, it doesn't work. Can anyone tell me how I'm supposed to bind to my parent control from within a resource dictionary that's within Generic.xaml?
EDIT: This binding DOES work, but only for certain properties. I am unable to bind GradientStop Color to a dependency property of type color. It USED to work when this was a UserControl, but it doesn't work anymore now that I created a custom control. I don't know why, but if you're interested, I asked this question here:
Thanks everybody who helped,
Dalal