简体   繁体   中英

Extended WPF Toolkit - ChildWindow do not allow focus parent

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM