locked
drag and drop tabitem content RRS feed

  • Question

  • I have a TabControl that contains more TabItem with some controls in it. How can i drag & drop an object from one tab to a specific control in another tab.

    Basically how can i make the TabItem where i want to drop my object the selected one?

    Friday, April 22, 2011 8:26 AM

Answers

  • Hi Arhangel19,

    I think you can manually select a TabItem on mouse over to resolve this problem.

    Here is a simple sample.

          <TabControl.Resources>
            <Style TargetType="TabItem">
              <Setter Property="AllowDrop" Value="True"/>
              <EventSetter Event="DragEnter" Handler="TabItem_DragEnter"/>
            </Style>
          </TabControl.Resources>
    

        private void TabItem_DragEnter(object sender, DragEventArgs e)
        {
          TabItem tab = sender as TabItem;
          if (tab != null)
          {
            tab.IsSelected = true;
          }
        }
    

     

    Best regards,

     


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by ARHANGEL19 Tuesday, April 26, 2011 7:29 AM
    Tuesday, April 26, 2011 4:02 AM