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

WPF Radcombox can't handle "insert" keypress

1 Answer 146 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Ram asked on 15 Feb 2017, 09:01 AM

Hi All

I have a WPF RadComboBox within a RadDataForm as per below - however whenever I press "insert" on my keyboard the data on the form disappears.   

I have tried to handle the "Insert" keypress in the keydown and keyup events but to no avail, it doesn't drop in there - I need to be prevent the form data from disappearing when the insert key is pressed.

Is there a way to disable a certain key from being pressed?

Please help ASAP.



                 <StackPanel Margin="10,10,30,10">
                     <!--<telerik:DataFormDataField DataMemberBinding="{Binding Name,Mode=TwoWay}"
                         Label="Name" FontWeight="Bold"
                         IsEnabled="True" Width="580" LostFocus="event_OnIngredientNameLostFocus">
                     <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
                         <TextBlock KeyDown="RadComboBox_KeyDown" FontWeight="Bold" Margin="10,0,0,0" Text="Name" Width="180"/>
                         <telerik:RadComboBox ItemsSource="{Binding Glossary}"  SelectionChanged="event_OnIngredientNameSelectionChanged"
                                    HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" LostFocus="event_OnIngredientNameLostFocus"
                                    Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"                                                                          
                                    VerticalAlignment="Top" KeyDown="RadComboBox_KeyDown"  KeyUp="RadComboBox_KeyUp" IsTextSearchEnabled="True" IsEditable="True" Width="355">
                             <Border BorderThickness="1" BorderBrush="{StaticResource ThemeAccent}">
                                 <Grid Background="#FFF3C6" MaxWidth="260" MinWidth="100" Height="Auto">
                                         <RowDefinition Height="Auto" />
                                         <RowDefinition Height="1" />
                                         <RowDefinition Height="Auto" />
                                     <TextBlock Margin="3" TextOptions.TextFormattingMode="Display" Text="Ingredient Name" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Height="Auto" FontSize="14" FontWeight="SemiBold" HorizontalAlignment="Left" />
                                     <Rectangle Grid.Row="1" Height="1" HorizontalAlignment="Stretch" Margin="3,0" Fill="{StaticResource ThemeStripe}" />
                                     <TextBlock Margin="3" TextOptions.TextFormattingMode="Display" TextAlignment="Left" Grid.Row="2" Text="Start typing to select the ingredient or additive name from the glossary" TextWrapping="Wrap" Height="Auto" FontSize="12" FontWeight="Normal" HorizontalAlignment="Left" />
                                 <VirtualizingStackPanel />
                     <telerik:DataFormDataField DataMemberBinding="{Binding RefCode,Mode=TwoWay}"
                         Label="Ref Code"
                         IsEnabled="True" Width="580">



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 17 Feb 2017, 08:16 AM
Hi Ram,

We already replied in the support ticket. However I will paste the reply here in order to be available to the community:

When pressing the Insert key the RadDataForm is adding a new item by default. You might see an empty window since you have probably not set a NewItemTemplate for your RadDataForm. If you would like to disable this behavior, you can handle the PreviewKeyDown event of the RadDataForm and set the e.Handled event to True:
private void RadDataForm_PreviewKeyDown(object sender, KeyEventArgs e)
    if (e.Key == Key.Insert)
        e.Handled = true;

You can also create a custom keyboard command provider and handle the case of pressing the Insert key. You can check the following article - RadDataForm Keyboard Support.

Hope this helps.

Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question