using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace LLControls.UserControls { public partial class Test : UserControl { private static readonly DependencyProperty TargetControlProperty; static Test() { FrameworkPropertyMetadata fm = new FrameworkPropertyMetadata(); fm.PropertyChangedCallback = TargetChanged; TargetControlProperty = DependencyProperty.Register("TargetControl", typeof(ILLObject), typeof(Test), fm); } public Test() { InitializeComponent(); if (!BindingOperations.IsDataBound(this, TargetControlProperty)) //Always false at this point CanvasHolder.CurrentElementChanged += new CanvasHolder.CurrentElementChangedEventHandler(CurrentElementChanged); } public ILLObject TargetControl { get { return (ILLObject)GetValue(TargetControlProperty); } set { SetValue(TargetControlProperty, value); } } private static void TargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((Test)d).CurrentElementChanged((ILLObject)e.NewValue); return; } void CurrentElementChanged(ILLObject ilo) { } } }The idea here is that normally we handle the CanvasHolder.CurrentElementChanged event. However the XAML designer may wish to use this class by binding to the TargetControlProperty in XAML. When this happens I don't want to have the event wired up but to just use the XAML binding instead. The problem with the above code is that the .IsDataBound() in the initializer always returns false so I can't make the decision there. The only other option I can see would be to always wire up the handler in the initializer and then remove it in the TargetChanged method if it is called but this feels messy (to say the least).