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

Controls inside RadComboBox not useable

1 Answer 78 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 1
Warren asked on 14 Dec 2011, 06:31 AM
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";
    }
}

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 15 Dec 2011, 01:28 PM
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 >>

Tags
ComboBox
Asked by
Warren
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or