This is a migrated thread and some comments may be shown as answers.

[window].Show/ShowDialog within MouseDoubleClick of Treeview causes loss of mouse events in child window.

2 Answers 93 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Rex Walker
Top achievements
Rank 1
Rex Walker asked on 03 Oct 2011, 05:36 PM

When performing a ShowDialog (and even .Show) of WPF Window within the MouseDoubleClick event of the RadTreeView, mouse events (MouseEnter, Click, etc..) no longer fire in the Dialogue Window.  It gives the appearance of hanging, but keyboard nav functions just fine.

Interestingly, by moving focus to a different window and alt-tabbing back to the dialogue, the mouse events are once again detected.
I have only noticed this in the MouseDoubleClick event. 

The workaround that I am using to avoid this problem is to set a flag in the MouseDoubleClick event and then check the flag in the MouseLeftButtonUp event.    If I fire the .Show or .ShowDialog from the MouseLeftButtonUp event, all is OK and the problem does not appear. 


Details
VS 2010 Ultimate
Telerik - WPF 2011 Q2 - SP1
Win 7 - 64

Reproduce
Create WPF Application with two windows (MainWindow and TestDLG)
Build/Run
Double Click on Item 1
Hit Cancel Button
If it doesn't appear to lock on first try, repeat.  Always get it to lock before doing this three or four times.

When it locks, just Alt-Tab out and then back to the test application and the mouse lives again.

This sample is as simple as I could make.

<Window x:Class="MainWindow"
    Title="MainWindow" Height="280" Width="400"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid>
        <telerik:RadTreeView Height="128"
                             HorizontalAlignment="Left"
                             Margin="160,72,0,0"
                             Name="RadTreeView1"
                             VerticalAlignment="Top"
                             BorderThickness="1"
                             BorderBrush="Black"
                             Width="125">
            <telerik:RadTreeViewItem DropPosition="Inside"
                                     Header="Item 1" />
        </telerik:RadTreeView>
    </Grid>
</Window>

MainWindow - Code Behind

Class MainWindow
 
    Private Sub RadTreeView1_MouseDoubleClick(sender As Object, e As System.Windows.Input.MouseButtonEventArgs) Handles RadTreeView1.MouseDoubleClick
        Dim tw As New TestDLG
        tw.ShowDialog()
        tw.Close()
    End Sub
 
End Class

MainWindow CodeBehind (Workaround)
This is the workaround that allows the ShowDialog to occur on doubleclick event but not lose mouse events.

Class MainWindow
 
    Private _DidDoubleClick As Boolean
    Private Sub RadTreeView1_MouseDoubleClick(sender As Object, e As System.Windows.Input.MouseButtonEventArgs) Handles RadTreeView1.MouseDoubleClick
        _DidDoubleClick = True
    End Sub
 
    Private Sub RadTreeView1_MouseLeftButtonUp(sender As Object, e As System.Windows.Input.MouseButtonEventArgs) Handles RadTreeView1.MouseLeftButtonUp
        If _DidDoubleClick Then
            _DidDoubleClick = False
            Dim tw As New TestDLG
            tw.ShowDialog()
            tw.Close()
        End If
    End Sub
End Class

Dialog Window

<Window x:Class="TestDLG"
    Title="TestDLG" Height="300" Width="300">
    <Grid>
        <Button Content="Button"
                Height="29"
                HorizontalAlignment="Left"
                Margin="82,204,0,0"
                Name="Button1"
                VerticalAlignment="Top"
                Width="97" />
    </Grid>
</Window>


Dialog Window CodeBehind

Public Class TestDLG
 
    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Me.Hide()
    End Sub
End Class

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 06 Oct 2011, 03:24 PM
Hi Rex Walker,

 We agree that this does not work properly in the RadTreeView but this event is inherited and we highly suggest you to use the ItemDoubleClick event instead. You can find this realized in the attached sample. Please let us know if this fits in your scenario.

Public Partial Class MainWindow
    Inherits Window
    Public Sub New()
        InitializeComponent()
        Me.RadTreeView1.ItemDoubleClick += New EventHandler(Of Telerik.Windows.RadRoutedEventArgs)(AddressOf RadTreeView1_ItemDoubleClick)
    End Sub
 
    Private Sub RadTreeView1_ItemDoubleClick(sender As Object, e As Telerik.Windows.RadRoutedEventArgs)
        Dim ww As New Window1()
        ww.ShowDialog()
        ww.Close()
    End Sub
End Class
Best wishes,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rex Walker
Top achievements
Rank 1
answered on 06 Oct 2011, 04:22 PM
Thank you for the info. 

ItemDoubleClick performs as expected.
Tags
TreeView
Asked by
Rex Walker
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Rex Walker
Top achievements
Rank 1
Share this question
or