简体   繁体   中英

Why are the controls in my new WPF window frozen?

So I'm dealing with problem on my WPF app. I need to call popup window with few controls (textboxes, buttons).

So i created new window:

<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,0" VerticalAlignment="Top" Height="26" Width="86"/>
        <Label Content="New Password: " HorizontalAlignment="Left" Margin="45,51,0,0" VerticalAlignment="Top" Height="26" Width="86"/>
        <Label Content="Confirm Password: " HorizontalAlignment="Left" Margin="37,82,0,0" VerticalAlignment="Top" Height="26" Width="107"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,20,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,51,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="144,82,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
        <Button Content="OK" HorizontalAlignment="Left" Margin="63,132,0,0" VerticalAlignment="Top" Width="75"/>
        <Button Content="Cancel" HorizontalAlignment="Left" Margin="162,132,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
    </Grid>
</Window>

And i call my window like this:

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

Problem is every control is frozen in that window. I cant write into textboxes or click buttons. I can resize the window i can close it.

PS: Main window in behind is still working fine.

Any suggestions what could cause this?

Remove the IsHitTestVisible="False" attribute in your AppPasswordWindow . It prevents hit testing and thus prevents the framework from detecting mouse events.

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