i am new to WPF so i am stuck with some binding on my customcontrol click button.
I have textbox that has watermark and selctedItems properties. Control if selectedi
Finally i manage to make it work, with help and guidance from Jaun it still didnt work (i tried probably 10 different things and it was in DataContext .. it was never binded.
So on my override OnApplyTemplate i added this.DataContext = this ... so i missed that part.
I used AttachedCommandBehavior (nuget) for command
code:
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.DataContext = this;
ItemsControl itmControl = GetTemplateChild("PART_SelectedItemsHost") as ItemsControl;
if (itmControl != null)
{
itmControl.MouseLeftButtonDown += new MouseButtonEventHandler(itmControl_MouseLeftButtonDown);
// blind click on X buttons in ItemsControl
}
}