Events get unsubscribed after dragging of tabcontrol

Posted by: vinothkumar.r2210 on 13 May 2020, 1:11 am EST

  • Posted 13 May 2020, 1:11 am EST

    Hi,
    I have added one button in DockTabControl ControlTemplate.In the loaded event of DockTabControl i have assigned click event for that button. When clicking, click event got executed. After dragging of DockTabControl, click event is not fired.

    private void DockTabControl_Loaded(object sender, RoutedEventArgs e)
    {
    var tab = (DockTabControl)sender;
    if (tab != null)
    {
    Button filterButton = FindChild<Button>(tab, "FilterButton");
    if (filterButton != null)
    {
    filterButton.Click += FilterButton_Click;
    }
    }
    }

    private void FilterButton_Click(object sender, RoutedEventArgs e)
    {
    FilterExecutedEventArgs filterExecutedEventArgs = new FilterExecutedEventArgs("Test");
    FilterEventHandler filterEventHandler = FilterExecutedEvent;
    if(FilterExecutedEvent != null)
    {
    FilterExecutedEvent(sender, filterExecutedEventArgs);
    }
    }
    Thanks and Regards,
    Vinoth Kumar Ravi
  • Marked as Answer

    Replied 13 May 2020, 11:53 pm EST

    Hi Vinoth,

    This is expected. When you drag the DockTabControl out of DockControl, the items of DockControl change, That is, before dragging the C1DockControl.Items would have a child (like DockGroup) and this child will further contain the DockTabControl in Item's collection, but as soon as you float the DockTabControl, its parent changes as it becomes a direct child of DockControl.
    So, you should keep track of DockControl Items and add handler to the DockTabControl that has the specific name.

    Thanks,
    Ruchir
  • Replied 14 May 2020, 5:04 pm EST

    Hi Ruchir,

    Thanks for the reply. The i have to assign handlers to controls whenever DockControl ItemDockModeChanged.

    Thanks and Regards,
    Vinoth Kumar Ravi
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels