Hi!
I have an AutoCompleteBox [ACB] from the WPF Toolkit in a ContentPane of the DocumentContentHost. When the ACB has focus after choosing an item I can't change the tab anymore with the first click. I have to click two times to get the right tab. Do you know why? Here is my code for example:
<Window xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDock="http://infragistics.com/DockManager" Title="MainWindow" Height="350" Width="525" > <Grid> <igDock:XamDockManager Name="XamDockManager1"> <igDock:DocumentContentHost> <igDock:SplitPane> <igDock:TabGroupPane> <igDock:ContentPane Header="File 1"> <Grid> <my:AutoCompleteBox x:Name="ACB1" Width="150" Height="25"/> </Grid> </igDock:ContentPane> <igDock:ContentPane Header="File 2"> <Grid> <TextBlock Text="File 2-Tab"/> </Grid> </igDock:ContentPane> </igDock:TabGroupPane> </igDock:SplitPane> </igDock:DocumentContentHost> </igDock:XamDockManager> </Grid></Window>
Code-behind:
Class MainWindow Public Sub New() InitializeComponent() Dim StrArray = New String() {"Aab", "Abb", "Abc"} ACB1.ItemsSource = StrArray End SubEnd Class
This looks like a bug in the AutoCompleteBox. Basically they are handling the IsKeyboardFocusWithinChanged. In response to that they call off to their FocusChanged helper method. When that goes to false they are calling the Select method of their TextBox. Well calling Select on a textbox results in the TextView trying to reposition its CaretElement. That results in it calling BringIntoView. Nothing is handling the RequestBringIntoView between it and the TabGroupPane. The TabGroupPane has to process that request and so it ends up selecting the tab that contains that autocompletebox which is why it seems like you can't change tabs - it does change but then it changes back because of the caretelement's request to be brought into view. You could probably handle this by hooking the RequestBringIntoView on the ACB and marking it handled. e.g.
private void ACB1_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e){ AutoCompleteBox acb = sender as AutoCompleteBox; if (acb.IsVisible == false && e.OriginalSource != acb) e.Handled = true;}
if (acb.IsVisible == false && e.OriginalSource != acb) e.Handled = true;}
Thank you. Your code works great.
Sincerely,
voks