Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:26:21+00:00 2026-06-04T16:26:21+00:00

Is it possible to rearrange tab items in tab control in run time? For

  • 0

Is it possible to rearrange tab items in tab control in run time? For example I have 3 tab items which are about cars and 4 tabs about house. I want to be able to rearrange them using drag and drop. Is it possible or it is something fantastic?

I have Tab Control here is XAML.

<TabControl x:Name="tc" Visibility="Collapsed" GotFocus="Focus" AllowDrop="True" >
            </TabControl>

Tab items will be added in runtime.
Thanks for helping me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:26:23+00:00Added an answer on June 4, 2026 at 4:26 pm

    found a solution in the MSDN forum.

    Here is the link:

    DragDrop TabItem

    Here is the solution:

    C# solution

    WPF code:

    <TabControl>
        <TabControl.Resources>
            <Style TargetType="TabItem">
                <Setter Property="AllowDrop" Value="True"/>
                    <EventSetter Event="PreviewMouseMove" Handler="TabItem_PreviewMouseMove"/>
                    <EventSetter Event="Drop" Handler="TabItem_Drop"/>
            </Style>
        </TabControl.Resources>
    
        <TabItem Header="Tabitem 1"/>
        <TabItem Header="Tabitem 2"/>
        <TabItem Header="Tabitem 3"/>
        <TabItem Header="Tabitem 4"/>
        <TabItem Header="Tabitem 5"/>
    </TabControl>
    

    C# code behind:

    private void TabItem_PreviewMouseMove(object sender, MouseEventArgs e)
    {
        if (!(e.Source is TabItem tabItem))
        {
            return;
        }
    
        if (Mouse.PrimaryDevice.LeftButton == MouseButtonState.Pressed)
        {
            DragDrop.DoDragDrop(tabItem, tabItem, DragDropEffects.All);
        }
    }
    
    private void TabItem_Drop(object sender, DragEventArgs e)
    {
        if (e.Source is TabItem tabItemTarget &&
            e.Data.GetData(typeof(TabItem)) is TabItem tabItemSource &&
            !tabItemTarget.Equals(tabItemSource) &&
            tabItemTarget.Parent is TabControl tabControl)
        {
            int targetIndex = tabControl.Items.IndexOf(tabItemTarget);
    
            tabControl.Items.Remove(tabItemSource);
            tabControl.Items.Insert(targetIndex, tabItemSource);
            tabItemSource.IsSelected = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do you rearrange buttons where you want them in Eclipse? Hey
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
As a result of changes in the company, we have to rearrange our sitting
here's my dilema. I have for example this string: 1 2 3 4 5
Is it possible to rearrange a table's column order in SQL yog?
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
I have the result of a certain query which I have to display in
Imagine I have a vertex array and an index array. Suppose it is possible
I have a UITableView which lies in a NavigationController that is in a popover.
I have a number of items in an array, each one associated to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.