Hi,
In my application, i want to bind an object to a new dependency property which i have created. But i am not able to assign it correctly. If i assign the same object tp DataContext of the UserControl then the DataContext gets the assigned object.
Here is my code below, whats wrong with the code below:
public IElementProvider Data { get { return (IElementProvider)GetValue(DataProperty); } set { SetValue(DataProperty, value); } } // Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc... public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(IElementProvider), typeof(UserControl1), new PropertyMetadata(new PropertyChangedCallback(SpecialChangedPropertyCallback))); private static void SpecialChangedPropertyCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { UserControl1 myUserControl = (UserControl1)d; // I want to assign the new Dependency Property to some other object here } // My XAML code<Views:UserControl1 x:Name="myUserControl1" DataContext="{Binding Path=Parameters}" Data="{Binding DataContext, RelativeSource={RelativeSource Self}}" >
I tried various binding options for 'Data' property but still could not get it work. Can someone help me?
Thanks,
IamHuM