私の WPF アプリケーションには、データベースの検索を実行するためのフォームがあります。プロパティが true に設定されているButton
検索を開始する があります。IsDefault
通常、これにより、Button's Click
フォームで Enter キーを押したときにイベントが発生します。
検索結果は、TelerikRadGridView
コントロールに表示されます。元々、結果の行をダブルクリックすると、プログラムは別のタブに移動し、クリックした行の詳細を表示していました。RadGridView
上司から、Enter キーを押したときにコントロールが同じことを行うように を変更するように依頼されました。
プログラムに詳細を表示するためのカスタム コマンドを追加CommandBindings
し、検索コントロールの XAML にセクションを追加することで、これを実現できました。次にInputBindings
、XAML にセクションを追加するRadGridView's
と、すべてが機能します。ただし、Enter キーを押してもデフォルトButton's Click
イベントは発生しません。
<UserControl x:Class="CarSystem.CustomControls.Searcher"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:cs="clr-namespace:CarSystem.CustomControls"
xmlns:vm="clr-namespace:CarSystem.ServiceModel;assembly=ViewModels"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Height="620"
IsVisibleChanged="Searcher_IsVisibleChanged"
Loaded="Searcher_Loaded"
Width="990">
<UserControl.CommandBindings>
<CommandBinding CanExecute="DisplayEditHotListEntry_CanExecute" Command="cs:CarSystemCommands.DisplayEditHotListEntry" Executed="DisplayEditHotListEntry_Executed" />
<CommandBinding CanExecute="DisplayEditRecordDetails_CanExecute" Command="cs:CarSystemCommands.DisplayEditRecordDetails" Executed="DisplayEditRecordDetails_Executed" />
</UserControl.CommandBindings>
<Grid Background="{DynamicResource ContentBackground}"
Name="LayoutRoot">
. . .
<telerik:RadGridView . . .>
. . .
<telerik:RadGridView.InputBindings>
<KeyBinding Key="Enter" Command="{x:Static cs:CarSystemCommands.DisplayEditHotListEntry}" />
</telerik:RadGridView.InputBindings>
</telerik:RadGridView>
<Button IsDefault="true" . . . />
</Grid>
</UserControl>
フォームの上部には、検索条件を指定する多数のコントロールがあります。Button's Click
フォーカスがこれらのコントロールの 1 つにあるときに Enter キーを押して、デフォルトイベントを起動し、フォーカスが にあるときに新しいアクションを実行したいと思いますRadGridView
。これを機能させるにはどうすればよいですか?