为什么我的新WPF窗口中的控件被冻结?

所以我正在处理WPF应用程序中的问题。我需要用很少的控件(文本框,按钮)调用弹出窗口。

所以我创建了新窗口:

<Window x:Class="Ultra_Script_WPF.User_Settings.AppPasswordWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Ultra_Script_WPF.User_Settings"
        mc:Ignorable="d"
        Title="AppPasswordWindow" Height="229.5" Width="360" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" IsHitTestVisible="False">
    <Grid Background="AliceBlue">
        <Label Content="Old Password: " HorizontalAlignment="Left" Margin="45,20,0" VerticalAlignment="Top" Height="26" Width="86"/>
        <Label Content="New Password: " HorizontalAlignment="Left" Margin="45,51,0" VerticalAlignment="Top" Height="26" Width="86"/>
        <Label Content="Confirm Password: " HorizontalAlignment="Left" Margin="37,82,0" VerticalAlignment="Top" Height="26" Width="107"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
        <Button Content="OK" HorizontalAlignment="Left" Margin="63,132,0" VerticalAlignment="Top" Width="75"/>
        <Button Content="Cancel" HorizontalAlignment="Left" Margin="162,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
    </Grid>
</Window>

我这样叫我的窗户:

AppPasswordWindow apppasswordwindow = new AppPasswordWindow();
apppasswordwindow.Show();

问题是每个控件都冻结在该窗口中。我无法写入文本框或单击按钮。我可以调整窗口的大小,我可以关闭它。

PS:后面的主窗口仍然可以正常工作。

任何建议可能导致这种情况吗?

nhzjc 回答:为什么我的新WPF窗口中的控件被冻结?

删除IsHitTestVisible="False"中的AppPasswordWindow属性。它阻止了点击测试,从而阻止了框架检测鼠标事件。

本文链接:https://www.f2er.com/3148868.html

大家都在问