I've searched in as many ways as I can think to search and I haven't seen anyone mention this issue. Maybe I'm doing it wrong?
If I place an ExplorerBrowser control from the Windows API code pack in a WPF window and call Navigate() then tabbing through controls does not work after the the navigation is done. The only way to correct this is to actually click inside the browser control. Commenting out the Navigate call also stops it from happening but leaves a useless control.
The simplest use of the control demonstrates the issue.
<Window x:Class="TestApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WindowsPresentationFoundation="clr-namespace:Microsoft.WindowsAPICodePack.Controls.WindowsPresentationFoundation;assembly=Microsoft.WindowsAPICodePack.Shell"
Title="MainWindow" Height="600" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Name="box1" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,25,10,0" TabIndex="100"/>
<TextBox Name="box2" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,65,10,0" TabIndex="101"/>
<TextBox Name="box3" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,105,10,0" TabIndex="102"/>
<TextBox Name="box4" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,145,10,0" TabIndex="103"/>
<WindowsPresentationFoundation:ExplorerBrowser Grid.Column="1" Grid.Row="0" Name="aBrowser" Margin="5,2,5,5" TabIndex="200"/>
</Grid>
And
using Microsoft.WindowsAPICodePack.Shell;
using System;
using System.Windows;
namespace TestApp
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
string strPath = "C:\\test\\";
ShellObject folder = ShellObject.FromParsingName(strPath);
aBrowser.ExplorerBrowserControl.Navigate(folder);
}
}
}
Compile and launch, tabbing does not work. Click inside the browser control and it starts working again.
The problem only occurs when Navigate() completes. You can see this by placing the browser control inside a tab control.
<TabControl Grid.Column="1">
<TabItem/>
<TabItem>
<WindowsPresentationFoundation:ExplorerBrowser Grid.Column="1" Grid.Row="0" Name="aBrowser" Margin="5,2,5,5" TabIndex="200"/>
</TabItem>
</TabControl>
Add to MainWindow()
aBrowser.NavigationLog.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(FileNavComplete);
A function to handle it
public void FileNavComplete(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{ MessageBox.Show("Navigation complete"); }
Now when I compile and launch tabbing works until I click on the tab to bring the control to the foreground. The message box pops up, showing that Navigate() doesn't actually fire until the control is visible, and now tabbing no longer works unless I click in the control.
This is true for other windows in the project. If I were to open a dialog containing the control, let it Navigate, then close the window without clicking on the control.. tabbing is now broken for the entire application.
Any suggestions for either what to change or way to work around the issue would be awesome. Anything that's less hacky than moving the mouse cursor and clicking it programatically(yes, I tried and yes it works.).