Selection issues with TreeView in Ribbon

2 posts, 0 answers
  1. Paul
    Paul avatar
    5 posts
    Member since:
    Jan 2008

    Posted 09 Nov 2010 Link to this post

    I am experiencing issues when selecting nodes within a treeview within a ribbon.  Please see the following link to see what I am talking about: http://gis.hudson.oh.us/ribbon
    Select the "Select Map Views" dropdown button and you will see what I am referring to.  You need to click the node twice to execute the click event.  I only want the user to need to click ONCE.
    XAML:
    <telerik:RadRibbonDropDownButton x:Name="MapView_Button" Text="Map Theme" CollapseToSmall="WhenGroupIsSmall" Size="Large" 
    LargeImage="../Images/maptheme.png"  telerik:ScreenTip.Title="Select Map Theme"
    telerik:ScreenTip.Description="Use this tool to select a theme for the map such as sanitary sewer or water.  By selecting these themes, layers from the selected theme will be displayed"
      
    <telerik:RadRibbonDropDownButton.DropDownContent>
      
                        <StackPanel>
                        <telerik:RadGroupHeader Content="Clear Map Views"/>
                            <telerik:RadGallery ViewportHeight="50" ItemHeight="50" ItemWidth="250" ViewportWidth="250" >
                            <telerik:RadGalleryItem >
                                <telerik:RadRibbonButton x:Name="ClearMapView_Button" HorizontalAlignment="Center" Content="Clear Map View" Click="ClearMapView_Click" Padding="10" />
                            </telerik:RadGalleryItem>
                         </telerik:RadGallery>
                        <telerik:RadGroupHeader Content="Select Map View/Theme"></telerik:RadGroupHeader>
                            <telerik:RadGallery ViewportHeight="300" ItemHeight="300" ItemWidth="250" ViewportWidth="250" >
                                <telerik:RadGalleryItem>
                                    <StackPanel>
    <telerik1:RadTreeView x:Name="MapView_TreeView" Background="Transparent" BorderThickness="0" />
                                    </StackPanel>
                            </telerik:RadGalleryItem>
    </telerik:RadGallery>
                        </StackPanel>
      
                    </telerik:RadRibbonDropDownButton.DropDownContent>
      
                </telerik:RadRibbonDropDownButton>

    VB:
    'Build map view treeview.
        Private Sub loadMapViewDropdown()
            Dim rootItem As Telerik.Windows.Controls.RadTreeViewItem = Nothing
            Dim childItem As Telerik.Windows.Controls.RadTreeViewItem
            Dim contentHolder As StackPanel
            Dim MVtextBlock As TextBlock
            Dim MVImage As Image
            Dim prevGroup As String = ""
            Dim mv As Globals.MapViews_Class
      
            'Init.
            MapView_Button.Text = ""
            MapView_Button.Text = "Set Map View"
            MapView_TreeView.Items.Clear()
      
            'Process all map views.
            For Each mv In Globals.MapViews
      
               'Add headings.
                If (mv.GroupName <> prevGroup) Then
                    prevGroup = mv.GroupName
                    rootItem = New Telerik.Windows.Controls.RadTreeViewItem
                    rootItem.Header = mv.GroupName
                    rootItem.Foreground = New SolidColorBrush(Colors.Black)
                    rootItem.IsExpanded = True
                    AddHandler rootItem.MouseLeftButtonUp, AddressOf mapViewClick
                    MapView_TreeView.Items.Add(rootItem)
      
                  End If
      
                'Define items for custom treeview items.
                contentHolder = New StackPanel
                MVImage = New Image
                MVtextBlock = New TextBlock
                childItem = New Telerik.Windows.Controls.RadTreeViewItem
      
                'Style Stackpanel
                contentHolder.Orientation = Orientation.Horizontal
                contentHolder.VerticalAlignment = Windows.VerticalAlignment.Center
      
                'Add image
                MVImage.Source = New BitmapImage(New Uri("../Images/" & mv.name & ".png", UriKind.Relative))
                contentHolder.Children.Add(MVImage)
                'Add text
                MVtextBlock.Text = mv.name
                MVtextBlock.VerticalAlignment = Windows.VerticalAlignment.Center
                contentHolder.Children.Add(MVtextBlock)
      
                childItem.Header = contentHolder
                childItem.Tag = mv.name
                childItem.Foreground = New SolidColorBrush(Colors.Black)
                childItem.Cursor = Cursors.Hand
                AddHandler childItem.MouseLeftButtonUp, AddressOf MapViewItem_Click
                rootItem.Items.Add(childItem)
      
                Next
      
            
        End Sub
      
        'Mapview treeview item selected event.
        Private Sub MapViewItem_Click(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
            Dim tvi As Telerik.Windows.Controls.RadTreeViewItem = DirectCast(MapView_TreeView.SelectedItem, Telerik.Windows.Controls.RadTreeViewItem)
            If (tvi Is Nothing) Then
                Exit Sub
            End If
      
            Dim txt As String = tvi.Tag.ToString
      
            'Set map view for treeview children only.
            If (tvi.Items.Count = 0) Then
                Globals.ActiveMapView = txt
                highlightMapViewItem(tvi)
                Util.SetActiveIdentifyMapView()
                MapView_Button.LargeImage = New BitmapImage(New Uri("../Images/" & txt & ".png", UriKind.Relative))
            End If
        End Sub

    Thanks,

    Paul Leedham
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 11 Nov 2010 Link to this post

    Hi Paul,

    It appears that the DropDownButtonContent (which  is Popup) handles the MouseLeftButtonUp event.
    Therefore it is better to use the Selected event of the RadTreeView instead of the mentioned mouse event.
    Please give it a try and let me know if this works for you. Feel free to ask if you need further assistance or more info.  
     
    All the best,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top