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

RadWindow dialogs not closing when pressing Esc

6 Answers 179 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jochovader
Top achievements
Rank 1
Jochovader asked on 19 May 2014, 03:43 AM
Hi! 

Is there any special setting to allow the user to close the dialog window pressing the esc key?

Im using the latest (v.2014.1.331.1050)

I hope you can help me

Regards
JLuis

6 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 19 May 2014, 11:36 AM
Hello JLuis,

You can easily achieve the desired by implementing an attached property which subscribes to the KeyDown event of the RadAlert dialog. In the event handler you would need to get the Parent of the RadAlert and call its Close method. For your convenience I have attached a sample project which demonstrates the exact approach.

Hope this will work for you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jochovader
Top achievements
Rank 1
answered on 19 May 2014, 04:02 PM
Hi

One question: does this apply for out-of-browser apps? 
For some reason the OnKeyDownEventHandler is not launching.

Regads
JLuis
0
Jochovader
Top achievements
Rank 1
answered on 19 May 2014, 04:12 PM
This is the style currently applied to the RadWindow.

Do you think this interfere in some way with the helper?

<Style TargetType="telerikNavigation:RadAlert"
                           BasedOn="{StaticResource RadAlertStyle}">
                        <Setter Property="IsTabStop"
                                Value="false" />
                        <Setter Property="MinWidth"
                                Value="275" />
                        <Setter Property="MaxWidth"
                                Value="500" />
                        <Setter Property="helpers:DialogKeyHelper.IsKeyEnabled"
                                Value="True" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="telerikNavigation:RadAlert">
                                    <Grid x:Name="LayoutRoot">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <telerik:CommandManager.InputBindings>
                                            <telerik:InputBindingCollection>
                                                <telerik:KeyBinding Key="Escape"
                                                                    Command="telerik:WindowCommands.Confirm" />
                                            </telerik:InputBindingCollection>
                                        </telerik:CommandManager.InputBindings>
                                        <ContentPresenter x:Name="Icon"
                                                          VerticalAlignment="Top"
                                                          Margin="16 8 8 8"
                                                          ContentTemplate="{StaticResource AlertIconTemplate}" />
                                        <ScrollViewer IsTabStop="False"
                                                      Grid.Row="0"
                                                      Grid.Column="1"
                                                      HorizontalScrollBarVisibility="Auto"
                                                      VerticalScrollBarVisibility="Auto"
                                                      Margin="0 0 0 7"
                                                      BorderBrush="{x:Null}">
                                            <ContentPresenter x:Name="AlertText"
                                                              Margin="8 8 8 0" />
                                        </ScrollViewer>
                                        <Border x:Name="HorizontalRule"
                                                Grid.Row="1"
                                                Grid.ColumnSpan="2"
                                                Height="1"
                                                Background="{StaticResource BasicBrush}"
                                                VerticalAlignment="Top" />
                                        <telerik:RadButton x:Name="OK"
                                                           Command="telerik:WindowCommands.Confirm"
                                                           telerikNavigation:RadWindow.ResponseButton="Accept"
                                                           Grid.Row="2"
                                                           Grid.ColumnSpan="2"
                                                           MinWidth="70"
                                                           HorizontalAlignment="Right"
                                                           telerik:LocalizationManager.ResourceKey="Ok"
                                                           Margin="0 10 8 8" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
0
Kalin
Telerik team
answered on 20 May 2014, 02:13 PM
Hi JLuis,

I tested the provided Style with out of browser application and everything worked as expected. The Alert was closing when the escape button is pressed. I'm attaching the project here, please test it and let me know if it works for you, if not I'll ask you to modify it in order to reproduce your scenario.

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jochovader
Top achievements
Rank 1
answered on 20 May 2014, 03:50 PM
Hi! I'd found that I had a control catching all the key strokes before the attached property.
The solution you provided works like a charm!

thank you so much
0
Kalin
Telerik team
answered on 21 May 2014, 07:47 AM
Hello JLuis,

I'm glad you have managed to achieve the desired. If you have any further questions or concerns, please do not hesitate to contact us.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Window
Asked by
Jochovader
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Jochovader
Top achievements
Rank 1
Share this question
or