Hi,
I have created a user control with a RadDropDownButton with a DataGrid as DropDownContent inside. To close the popup I have implemented a trigger action with a dependency property (to reference the RadDropDownButton) which is invoked whenever the selection of the DataGrid is changed.
public class CloseOnSelectionChangedTrigger : TriggerAction<UIElement> { protected override void Invoke(object parameter) { ((RadDropDownButton)this.Target).IsOpen = false; } public UIElement Target { get { return (UIElement)this.GetValue((TargetProperty)); } set { this.SetValue(TargetProperty, value); } } public static readonly DependencyProperty TargetProperty = DependencyProperty.Register("Target", typeof(UIElement), typeof(CloseOnSelectionChangedTrigger), new UIPropertyMetadata(null)); }
Unfortunately, when I use this user control in my MainWindow more then once I get a compiler error (sample project attached):
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=RadDropDownButton1'. BindingExpression:(no path); DataItem=null; target element is 'CloseOnSelectionChangedTrigger' (HashCode=58874610); target property is 'Target' (type 'UIElement')
Telerik version: 2016_2_503
What I'm doing wrong?
Regards