Problem with DialogBoxServiceProvider and GetFocusedElement() method

1 reply. Last post: May 27, 2013 4:42 AM by Yudi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Bill GowerMember

I am using the DialogBoxServiceProvider in my Wpf application. In the CloseCurrentWindow() method, the code is as follows:

FrameworkElementelement=ISFocusManager.GetFocusedElement()asFrameworkElement;
IWindowwindow=UXWindow.GetWindowHost(element);
 
if(window!=null)
window.Close();

When the user clicks the Save button on the dialog box, the save button is the GetFocusedElement and the dialog box successfully closes. I have a Close Batch button which is a UXToolBarButton in a UXToolGroup on a UXToolBar. When the user clicks the Close Batch, the code calls the DialogBoxServiceProvider.CloseCurrentWindow() method. The application crashes because GetFocusElement returns null. Why is a button on the UXDialogBox recognized as a FrameworkElement, but the button on the toolbar is not. Is that a bug? If not, how do i get the button on the tool bar to be returned as a frameworkElement like the save button?

All times are GMT -5. The time now is 2:22 AM.
Previous Next