简体   繁体   English

扩展的WPF工具包-ChildWindow不允许焦点父级

[英]Extended WPF Toolkit - ChildWindow do not allow focus parent

I have a ChildWindow that overlays a view that has inputs and buttons. 我有一个ChildWindow,它覆盖了具有输入和按钮的视图。 If the ChildWindow is opened i am not able to click any of the buttons which is good. 如果打开ChildWindow,我将无法单击任何一个好的按钮。 But with TAB i am able to switch the focus and select one of the buttons and hit enter. 但是使用TAB,我可以切换焦点并选择按钮之一,然后按Enter。

Any idea how I can prevent this? 知道如何防止这种情况吗?

Any help is appreciated... 任何帮助表示赞赏...

The code is really simple and nothing special... 代码真的很简单,没有什么特别的...

MainWindow.xaml 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 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; 更新 :尝试在子窗口上将KeyboardNavigation.TabNavigation设置为Cycle; this should be a much better solution. 这应该是一个更好的解决方案。

You could try handling the PreviewLostKeyboardFocus event and simply not allowing it through; 您可以尝试处理PreviewLostKeyboardFocus事件,而根本不允许它通过; this should keep focus in your child window. 这应该将焦点放在您的子窗口中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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