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

Can't focus after closing a Confirm window

2 Answers 64 Views
Window
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 07 Mar 2014, 10:27 PM
                   When I close a cofirm radwindow  (showdialog()), it won't focus on a textbox.  If I change it to a regular wpf window and close it, everything is fine.
When I debug it and step through it, it works so it could be some race condition.

RadWindow.Confirm(new DialogParameters(){
 Owner = myMainpage,
                    DialogStartupLocation = WindowStartupLocation.CenterOwner,
                    Content =
                        message,
                    Closed = Cancel_Click
 ...
        private void Cancel_Click(object sender, Telerik.Windows.Controls.WindowClosedEventArgs e)
        {

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (System.Threading.ThreadStart)delegate()
            {

                myTextBox.Focus();
            });
//set the focus here

2 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 12 Mar 2014, 11:46 AM
Hello Dan,

We were able to reproduce the described issue and I logged it in our Feedback portal. You can easily track its status on the following link:
http://feedback.telerik.com/Project/143/Feedback/Details/122613-it-is-not-possible-to-focus-other-element-in-the-closed-event-handler-of-the-radw

What I can suggest as a workaround would be to use a DispatcherTimer in order to focus the TextBox a little bit later. So if you are opening the Confirm dialog with a Button the code behind should looks as follows:

private DispatcherTimer timer;
public MainWindow()
{
    InitializeComponent();
    timer = new DispatcherTimer();
    timer.Interval = new TimeSpan(0, 0, 0, 0, 600);
    timer.Tick += timer_Tick;
}
 
void timer_Tick(object sender, EventArgs e)
{
    myTextBox.Focus();
    timer.Stop();
}
 
private void Cancel_Click(object sender, Telerik.Windows.Controls.WindowClosedEventArgs e)
{
    timer.Start();
}
 
private void Button_Click(object sender, RoutedEventArgs e)
{
    RadWindow.Confirm(new DialogParameters()
    {
        Owner = Application.Current.MainWindow,
        DialogStartupLocation = WindowStartupLocation.CenterOwner,
        Content = "Test",
        Closed = Cancel_Click,
    });
}

Hope this will work for you. I have also updated your Telerik points for your involvement.

Regards,
Kalin
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
0
danparker276
Top achievements
Rank 2
answered on 12 Mar 2014, 05:25 PM
Thanks the workaround is great
Tags
Window
Asked by
danparker276
Top achievements
Rank 2
Answers by
Kalin
Telerik team
danparker276
Top achievements
Rank 2
Share this question
or