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

  • Home
  • SEARCH
  • 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 4623638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:01:03+00:00 2026-05-22T03:01:03+00:00

In my TreeView , I have different events for MouseDown / MouseUp , etc

  • 0

In my TreeView, I have different events for MouseDown/MouseUp, etc but when I do it fast enough the TreeView expands/collapses the TreeNode. I don’t want this baked-in behaviour.

Is there a way to disable this?

  • 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-05-22T03:01:04+00:00Added an answer on May 22, 2026 at 3:01 am

    You could suppress the double click event of TreeViewItem like so:

    xaml:

    <TreeView DockPanel.Dock="Left" TreeViewItem.PreviewMouseDoubleClick="TreeViewItem_PreviewMouseDoubleClick">
        <TreeViewItem Header="Node Level 1" IsExpanded="True" >
            <TreeViewItem Header="Node Level 2.1" >
                <TreeViewItem Header="MyItem" />
            </TreeViewItem>
            <TreeViewItem Header="Node Level 2.2">
                <TreeViewItem Header="MyItem" />
            </TreeViewItem>
        </TreeViewItem>
    </TreeView>
    

    code:

    private void TreeViewItem_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        //this will suppress the event that is causing the nodes to expand/contract 
        e.Handled = true;
    }
    

    UPDATE

    According to msdn docs:

    Although this routed event seems to
    follow a tunneling route through an
    element tree, it actually is a direct
    routed event that is raised along the
    element tree by each UIElement…
    Control authors who want to handle
    mouse double clicks should use the
    PreviewMouseLeftButtonDown event when
    ClickCount is equal to two. This will
    cause the state of Handled to
    propagate appropriately in the case
    where another element in the element
    tree handles the event.

    I’m not sure if this why you are having issues or not, but we’ll do it the MSDN way and use PreviewMouseLeftButtonDown instead:

    xaml:

    <TreeView DockPanel.Dock="Left" TreeViewItem.PreviewMouseLeftButtonDown="TreeView_PreviewMouseLeftButtonDown">
        <TreeViewItem Header="Node Level 1" IsExpanded="True">
            <TreeViewItem Header="Node Level 2.1" >
                <TreeViewItem Header="MyItem" />
            </TreeViewItem>
            <TreeViewItem Header="Node Level 2.2">
                <TreeViewItem Header="MyItem" />
            </TreeViewItem>
        </TreeViewItem>
    </TreeView>
    

    code:

    private void TreeView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ClickCount > 1)
        {
            //here you would probably want to include code that is called by your
            //mouse down event handler.
            e.Handled = true;
        }
    }
    

    I’ve tested this and it works no matter how many times i click

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a treeview, where each treenode contains an id for a different
I have a treeview (winforms) which have different item types on it. I have
I have a treeview with nodes like this: Foo (1234), and want to allow
I have a TreeView windows forms control with an ImageList , and I want
I have a treeview in my masterpage. When a contentpage is loaded i want
I have a TreeView in my form for which I dont want to have
As title, is it possible? I have seen in TreeView you can defines different
I have three tree view controls which house different (but mostly similar data), as
I have a treeview in my C# code. I want to replace all existing
I have a Treeview with populateOnDemand set to true. I want this treeview to

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.