I have a ChildWindow that overlays a view that has inputs and buttons. If the ChildWindow is opened i am not able to click any of the buttons which is good. But with TAB i am able to switch the focus and select one of the buttons and hit enter.
Any idea how I can prevent this?
Any help is appreciated...
The code is really simple and nothing special...
MainWindow.xaml
<Grid>
<xctk:ChildWindow Name="chWindow" IsModal="True" WindowStartupLocation="Center">
<TextBlock Text="Hello World ..." />
</xctk:ChildWindow>
<StackPanel>
<Button Content="Load" Click="OnLoadClicked"/>
<Button Content="Re-Initialize" Click="OnInitClicked"/>
<Button Content="Modal dialog" Click="OnModalClicked" />
<ListBox x:Name="listBox" />
</StackPanel>
</Grid>
MainWindow.xaml.cs
public MainWindow(IModuleCatalog moduleCatalog, IModuleManager moduleManager)
{
InitializeComponent();
this.DataContext = this;
this.ConfirmationRequest = new InteractionRequest<IConfirmation>();
this.moduleCatalog = moduleCatalog;
this.moduleManager = moduleManager;
UpdateModulesList();
this.Loaded += (s, e) => this.chWindow.Show();
}
Update: try setting KeyboardNavigation.TabNavigation to Cycle on the child window; this should be a much better solution.
You could try handling the PreviewLostKeyboardFocus event and simply not allowing it through; this should keep focus in your child window.