I have a rather simple problem, but I am unable to get my head around it...
I have a class that inherits from UserControl. It has an AxisColor DependencyProperty of type Color. In the XAML structure of the class I have <ms3DTools:ScreenSpaceLines3D Thickness="2" Points="0,0,0 100,0,0"  Color="{Binding Mode=OneWay, Path=AxisColor}".
The binding does not work. What am I doing wrong?
views:
38answers:
3
                
                A: 
                
                
              You probably want to add RelativeSource={RelativeSource Self} to the binding expression. Otherwise, you are binding to the DataContext property.
                  Daniel Pratt
                   2010-08-13 16:03:35
                
              Just tried it, but it not work...
                  licensedlice
                   2010-08-13 16:07:44
                
                
                A: 
                
                
              
            If you want UI binding then you have to specify ElementName, more options here. If you want data binding then make sure you have DataContext set up correctly.
                  Andrey
                   2010-08-13 16:03:38
                
              
                
                A: 
                
                
              If you have a UserControl that needs to get a Property AxisColor from a class, you need to set your DataContext of that UserControl to the class that contains AxisColor.
myUserControl.DataContext = myClassInstance;
Otherwise, your user control does not know where to grab the property from.
                  jsmith
                   2010-08-13 16:06:47
                
              Thanks, this worked...One more question: Is there an equivalent for this in XAML?
                  licensedlice
                   2010-08-13 16:38:37
                I guess I'm confused. I thought you said that the 'AxisColor' property was defined on the UserControl class itself. Did you just do 'myUserControl.DataContext = myUserControl;'?
                  Daniel Pratt
                   2010-08-13 16:47:34