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

3 posts, 0 answers
  1. Rex Walker
    Rex Walker avatar
    7 posts
    Member since:
    Oct 2009

    Posted 03 Oct 2011 Link to this post

    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. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 06 Oct 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Rex Walker
    Rex Walker avatar
    7 posts
    Member since:
    Oct 2009

    Posted 06 Oct 2011 Link to this post

    Thank you for the info. 

    ItemDoubleClick performs as expected.
Back to Top