public override object ProvideValue() { var binding = new Binding() { ElementName = ElementName }; TargetObject.SetBinding(ElementProperty, binding); Application.Current.Dispatcher.BeginInvoke(new Action(() => { var element = TargetObject.GetBindingExpression(ElementProperty).DataItem as FrameworkElement; FrameworkElement obj; if (VisualIndex > 0) { obj = element.FindVisualChild(VisualIndex); } else { if (string.IsNullOrEmpty(this.ChildName)) { obj = element.FindVisualChild(Type); } else { obj = element.FindVisualChild(ChildName); } } if (obj != null) { TargetObject.SetBinding(TargetProperty, new Binding() { Source = obj }); } }), System.Windows.Threading.DispatcherPriority.Render); return(null); }