WPF Popup tab key bug -


I have a WPF popup control with a list box and a button. When I click on the button, it should be disabled. The problem is that, when I disable the button, then the tab pops out of the popup. I have the isEnabled to wrong, tried to set the focus on the listbox, but if that was not working, how can I set tab focus to ListBox inside popup control?

This is my code.

Window1.xaml:

  & lt; Window x: orbit = "wpfApplication5.Window1" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/ 2006 / Xaml "title =" window 1 "height =" 300 "width =" 300 "& gt; & Lt; StackPanel & gt; & Lt; Button name = "open button" content = "open" /> & Lt; Popup name = "popup" placement = "center" & gt; & Lt; StackPanel & gt; & Lt; List Box Name = "List Box" / & gt; & Lt; Button name = "new item button" content = "new item" /> & Lt; / StackPanel & gt; & Lt; / Popup & gt; & Lt; / StackPanel & gt; & Lt; / Window & gt;  

Window 1.xaml.cs:

  System. Using Windows; Using System.Windows.Controls; Using System.Windows.Input; Namespace WpfApplication5 {partial squares window 1: window {public window 1 () {InitializeComponent (); OpenButton.Focus (); ListBox.ItemsSource = New String [] {"Item 1", "Item 2", "Item 3"}; List box. Selected index = 1; OpenButton.Click + = Rep? {Popup.IsOpen = true; }; Popup.Opened + = Representative {FocusListBox (); }; NewItemsButton.Click + = Delegate {newItemsButton.IsEnabled = false; FocusListBox (); }; } Focus listbox () {var i = listBox.ItemContainerGenerator.ContainerFromIndex (listBox.SelectedIndex) as ListBoxItem; If (i! = Null) keyboards Focus (i); }}}  

And here's a screenshot:

Edit later:

I have found a workaround, which is the focuslistbox (); Delaying call is delayed:

  Dispatcher.BusinessWeb (New Action (Focalistbox), Dispatcher PriorityInput); You need to define a clear focus area by setting the popup to:  

  & lt; Popup Focus Manager ISF focusoscope = "true" & gt; & Lt ;! - Your content goes here - & gt; & Lt; / Popup & gt;  

It focuses on focusing out the focus from the element.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -