Controls inside RadComboBox not useable

2 posts, 0 answers
  1. Warren
    Warren avatar
    1 posts
    Member since:
    Oct 2010

    Posted 14 Dec 2011 Link to this post

    I have a custom selection box template for a RadComboBox containing buttons, and then I handle the click events of those buttons to set values in my data.  This previously worked, but I just installed the latest version of the RadControls and now it doesn't work anymore, events don't seem to get routed to the buttons inside the combo box anymore, the combo box eats all the focus and click events itself without passing them on.

    I made a simple test app to show this happening, you'll notice when an item is selected, the buttons inside the combo box can't get focus and can't be clicked.

    <Window x:Class="RadControlsTest.MainWindow"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
        <Window.Resources>
            <DataTemplate x:Key="ComboBoxSelectionBoxTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                     
                    <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Text="{Binding TestData1}" FontSize="18.667" FontWeight="Bold" FontStyle="Italic"/>
                    <Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" />
                    <TextBlock Grid.Row="2" Grid.Column="0" Text="TestText1" HorizontalAlignment="Center" Margin="3,3,3,0" />
                    <TextBlock Grid.Row="2" Grid.Column="1" Text="TestText2" HorizontalAlignment="Center" Margin="3,3,3,0" />
                    <TextBlock Grid.Row="2" Grid.Column="2" Text="TestText3" HorizontalAlignment="Center" Margin="3,3,3,0" />
                    <TextBlock Grid.Row="2" Grid.Column="3" Text="TestText4" HorizontalAlignment="Center" Margin="3,3,3,0" />
                    <TextBlock Grid.Row="2" Grid.Column="4" Text="TestText5" HorizontalAlignment="Center" Margin="3,3,3,0" />
                    <telerik:RadButton Grid.Row="3" Grid.Column="0" Tag="0" Focusable="False" telerik:StyleManager.Theme="Office_Silver" Content="Button1" Click="ComboButton_Click" Margin="3" HorizontalAlignment="Center"/>
                    <telerik:RadButton Grid.Row="3" Grid.Column="1" Tag="1" Focusable="False" telerik:StyleManager.Theme="Office_Silver" Content="Button1" Click="ComboButton_Click" Margin="3" HorizontalAlignment="Center"/>
                    <telerik:RadButton Grid.Row="3" Grid.Column="2" Tag="2" Focusable="False" telerik:StyleManager.Theme="Office_Silver" Content="Button1" Click="ComboButton_Click" Margin="3" HorizontalAlignment="Center"/>
                    <telerik:RadButton Grid.Row="3" Grid.Column="3" Tag="3" Focusable="False" telerik:StyleManager.Theme="Office_Silver" Content="Button1" Click="ComboButton_Click" Margin="3" HorizontalAlignment="Center"/>
                    <telerik:RadButton Grid.Row="3" Grid.Column="4" Tag="4" Focusable="False" telerik:StyleManager.Theme="Office_Silver" Content="Button1" Click="ComboButton_Click" Margin="3" HorizontalAlignment="Center"/>
                </Grid>
            </DataTemplate>
        </Window.Resources>
            <Grid>
                <telerik:RadComboBox x:Name="TestComboBox" Margin="15,10" SelectionBoxTemplate="{StaticResource ComboBoxSelectionBoxTemplate}" Height="100" Width="320" />
            </Grid>
    </Window>



    And the relevant C# code for the main window

    public class TestData
    {
        public TestData(string test1) { TestData1 = test1; }
     
        public string TestData1 { get; set; }
    }
     
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        List<TestData> m_TestDataList = new List<TestData>();
         
        public MainWindow()
        {
            m_TestDataList.Add(new TestData("test1"));
            m_TestDataList.Add(new TestData("test2"));
            m_TestDataList.Add(new TestData("test3"));
            m_TestDataList.Add(new TestData("test4"));
             
            InitializeComponent();
        }
     
        private void ComboButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Button comboButton = (Button)sender;
            int index = (int)comboButton.Tag;
     
            MessageBox.Show("Clicked button " + index.ToString());
        }
     
        private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            TestComboBox.ItemsSource = m_TestDataList;
            TestComboBox.DisplayMemberPath = "TestData1";
        }
    }
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Dec 2011 Link to this post

    Hello Warren,

    We intentionally set IsHitTestVisible=false on the ContentPresenter that displays the SelectionBoxTemplate in order to allow RadComboBox to detect clicks regardless of the template content (by the way the standard WPF ComboBox works in the same way). You could edit the control template of RadComboBox and remove the IsHitTestVisible=false from the ContentPresenter with x:Name="Content" this should fix the problem.

    Best wishes,
    Valeri Hristov
    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
Back to Top