This is a migrated thread and some comments may be shown as answers.
ComboBox inside RadMenu
5 Answers 71 Views
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 16 Nov 2008, 05:20 AM
I have created a datatemplate for RadMenu where each menu item has a combobox.

The Menu is displaying just fine... The problem is... when I click on combobox... it doesn't drop down.
I see both DropDownOpened and DropDownClosed being fired back to back... I am not able to figure out who is firing DropDownClosed Event...

any help would be appreciated...

5 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 17 Nov 2008, 08:17 AM
Hello Rakesh,

I wasn't able to reproduce the problem you describe. Can you send us code sample so we can investigate it further. Thanks

Sincerely yours,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Rakesh
Top achievements
Rank 1
answered on 17 Nov 2008, 10:01 AM
<UserControl x:Class="SilverlightApplication4.Page" 
    xmlns:Telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
             xmlns:TelerikNav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
             xmlns:Custom="clr-namespace:SilverlightApplication4" 
             xmlns:ms="clr-namespace:System.Windows.Controls;assembly=System.Windows" 
             xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    Width="600" Height="500"
    <UserControl.Resources> 
        <Style TargetType="TelerikNav:RadMenuItem" x:Name="myStyle"
            <Setter Property="StaysOpenOnClick" Value="True"></Setter> 
        </Style> 
        <Custom:ListOfNodes x:Key="MyList"/> 
        <Custom:TaskListDataTemplateSelector x:Key="myDataTemplateSelector"/> 
        <Telerik:HierarchicalDataTemplate x:Key="Node" ItemsSource="{Binding Children}"
            <TextBlock Text="{Binding Name}" Foreground="Green"/> 
        </Telerik:HierarchicalDataTemplate> 
        <Telerik:HierarchicalDataTemplate x:Key="SelectionNode" ItemsSource="{Binding Children}"
            <Grid Width="240"
                <Grid.ColumnDefinitions> 
                    <ColumnDefinition x:Name="SelColumn1" Width="100"></ColumnDefinition> 
                    <ColumnDefinition x:Name="SelColumn2" Width="140"></ColumnDefinition> 
                </Grid.ColumnDefinitions> 
                <TextBlock x:Name="SelName" Foreground="Green" Text="{Binding Name}" Grid.Column="0" Grid.ColumnSpan="1"></TextBlock> 
                <ComboBox x:Name="selList" ItemsSource="{Binding SelectionData}" SelectedItem="{Binding SelectedData}" Grid.Column="1" Grid.ColumnSpan="1" Margin="20,0,20,0"></ComboBox> 
            </Grid> 
        </Telerik:HierarchicalDataTemplate> 
        <Telerik:HierarchicalDataTemplate x:Key="TextNode" ItemsSource="{Binding Children}"
            <Grid Width="240"
                <Grid.ColumnDefinitions> 
                    <ColumnDefinition x:Name="TxtColumn1" Width="100"></ColumnDefinition> 
                    <ColumnDefinition x:Name="TxtColumn2" Width="140"></ColumnDefinition> 
                </Grid.ColumnDefinitions> 
                <TextBlock x:Name="txtName" Text="{Binding Name}" Width="50" Grid.Column="0" Grid.ColumnSpan="1"></TextBlock> 
                <TextBox x:Name="txtData" Text="{Binding EnteredData}" Grid.Column="1" Grid.ColumnSpan="1" Margin="20,0,20,0"></TextBox> 
            </Grid> 
        </Telerik:HierarchicalDataTemplate> 
    </UserControl.Resources> 
        <Canvas x:Name="MenuCanvas" Grid.Row="0" Grid.RowSpan="1"
            <TelerikNav:RadMenu x:Name="Menu1" ClickToOpen="True" ItemsSource="{Binding Source={StaticResource MyList}}" ItemTemplateSelector="{StaticResource myDataTemplateSelector}" ItemContainerStyle="{StaticResource myStyle}"
            </TelerikNav:RadMenu> 
        </Canvas> 
</UserControl> 
 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using Telerik.Windows.Controls; 
using System.Xml.Serialization; 
using System.IO; 
using System.Xml; 
using System.Collections.ObjectModel; 
using System.ComponentModel; 
 
namespace SilverlightApplication4 
    public partial class Page : UserControl 
    { 
        public Page() 
        { 
            InitializeComponent(); 
        } 
    } 
 
    public class Node 
    { 
        protected Node _parent; 
        protected ObservableCollection<Node> _children; 
        protected string _name; 
 
        public Node(string name) 
        { 
            _name = name; 
            _children = new ObservableCollection<Node>(); 
            _children.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_children_CollectionChanged); 
        } 
 
        public Node Parent 
        { 
            get 
            { 
                return _parent; 
            } 
            set 
            { 
                _parent = value; 
            } 
        } 
 
        public ObservableCollection<Node> Children 
        { 
            get 
            { 
                return _children; 
            } 
        } 
 
        void _children_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
        { 
            foreach (Node node in e.NewItems) 
            { 
                node.Parent = this
            } 
        } 
 
        public string Name 
        { 
            get 
            { 
                return _name; 
            } 
        } 
    } 
 
    public class SelectionNode : Node 
    { 
        private List<string> _selectionData; 
 
        private string _selectedData; 
 
        public SelectionNode(string name) 
            : base(name) 
        { 
            _selectionData = new List<string>(); 
        } 
 
        public List<string> SelectionData 
        { 
            get { return new List<string> { "Item1""Item2""Item3" }; } 
            set { _selectionData = value; } 
        } 
 
        public string SelectedData 
        { 
            get { return _selectedData; } 
            set { _selectedData = value; } 
        } 
    } 
 
    public class TextNode : Node 
    { 
        private string _enteredData; 
 
        public TextNode(string name) 
            : base(name) 
        { 
 
        } 
 
        public string EnteredData 
        { 
            get 
            { 
                return _enteredData; 
            } 
            set 
            { 
                _enteredData = value; 
            } 
        } 
    } 
 
    public class TaskListDataTemplateSelector : DataTemplateSelector 
    { 
        HierarchicalDataTemplate nodeTemplate; 
        HierarchicalDataTemplate selectionNodeTemplate; 
        HierarchicalDataTemplate textNodeTemplate; 
 
        public TaskListDataTemplateSelector() 
        { 
        } 
 
        public override DataTemplate SelectTemplate(object item, DependencyObject container) 
        { 
            FrameworkElement page = Application.Current.RootVisual as FrameworkElement; 
            nodeTemplate = page.Resources["Node"as HierarchicalDataTemplate; 
            selectionNodeTemplate = page.Resources["SelectionNode"as HierarchicalDataTemplate; 
            textNodeTemplate = page.Resources["TextNode"as HierarchicalDataTemplate; 
 
            if (item.GetType() == typeof(Node)) 
            { 
                return nodeTemplate; 
            } 
            if (item.GetType() == typeof(SelectionNode)) 
            { 
                return selectionNodeTemplate; 
            } 
            if (item.GetType() == typeof(TextNode)) 
            { 
                return textNodeTemplate; 
            } 
 
            return null
        } 
    } 
 
 
    public class ListOfNodes : ObservableCollection<Node> 
    { 
        public ListOfNodes() 
        { 
            Node MasterNode = new Node("New Child"); 
            Node node1 = new SelectionNode("node1"); 
            Node nodeA = new SelectionNode("nodeA"); 
            Node nodeI = new SelectionNode("nodeI"); 
            Node nodeII = new SelectionNode("nodeII"); 
            Node nodeIII = new SelectionNode("nodeIII"); 
            nodeA.Children.Add(nodeI); 
            nodeA.Children.Add(nodeII); 
            nodeA.Children.Add(nodeIII); 
            Node nodeB = new SelectionNode("nodeB"); 
            Node nodeC = new Node("nodeC"); 
            Node nodeD = new Node("nodeD"); 
            node1.Children.Add(nodeA); 
            node1.Children.Add(nodeB); 
            node1.Children.Add(nodeC); 
            node1.Children.Add(nodeD); 
            Node node2 = new Node("node2"); 
 
            Node node3 = new Node("node3"); 
 
            Node node4 = new Node("node4"); 
 
            Node node5 = new Node("node5"); 
            Node nodeX = new TextNode("nodeX"); 
            Node nodeY = new Node("nodeY"); 
            Node nodeZ = new Node("nodeZ"); 
            node5.Children.Add(nodeX); 
            node5.Children.Add(nodeY); 
            node5.Children.Add(nodeZ); 
            MasterNode.Children.Add(node1); 
            MasterNode.Children.Add(node2); 
            MasterNode.Children.Add(node3); 
            MasterNode.Children.Add(node4); 
            MasterNode.Children.Add(node5); 
            Add(MasterNode); 
        } 
    } 
 
 
 
0
Rakesh
Top achievements
Rank 1
answered on 17 Nov 2008, 10:05 AM
probably the reason I see this is happening is because of MouseEnter event over RadMenuItem which is asking combobox to close.
if you debug and put a breakpoint at DropDownOpened event handler, it seems to work fine...
0
Rakesh
Top achievements
Rank 1
answered on 18 Nov 2008, 01:16 AM
Can somebody help me on this one please...
0
Hristo
Telerik team
answered on 18 Nov 2008, 07:52 AM
Hi Rakesh,

ComboBox close because it is loosing focus. We have fixed this behavior.
Later today or at the latest tomorrow we will release Service Pack 1 for RadControls for Silverlight 2 which will include the fix.
With the SP1 we will also release RadGridView for Silverlight 2.

Your Telerik points have been updated for reporting this.


Regards,
Hristo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Rakesh
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Rakesh
Top achievements
Rank 1
Share this question
or