弹出窗口打开时需要禁用Ui

时间:2013-05-22 08:13:51

标签: c# popup windows-store-apps

在我的Windows应用商店应用程序(c#)中,我有Popup:

<Popup x:Name="LoginPopup" HorizontalAlignment="Center" VerticalAlignment="Center" Width="400" Height="300" IsOpen="{Binding Path=LoginPopupIsOpen}">
            <Popup.ChildTransitions>
                <TransitionCollection>
                    <PopupThemeTransition />
                </TransitionCollection>
            </Popup.ChildTransitions>
</Popup>

当Popup IsOpen我只需要在Popup上处理事件并冻结所有其他UI(包括AppBar)。
没有创建工作区很少的全屏弹出窗口可以吗?

3 个答案:

答案 0 :(得分:0)

您可以使用两个属性在xaml.cs文件中执行此操作。 在您创建的弹出窗口的事件处理程序中,您可以包含以下两行

this.IsEnabled = false;
this.ApplicationBar.IsVisible = false;

在要关闭弹出窗口的事件处理程序中,可以将属性还原为原始值。

this.IsEnabled = true;
this.ApplicationBar.IsVisible = true;

答案 1 :(得分:0)

我也遇到了类似的问题并用它来处理。

        private void AlertMessage_Opened(object sender, object e)
    {
        UIBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
    }

    private void AlertMessage_Closed(object sender, object e)
    {
        UIBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
    }

我的弹出名称是AlertMessage,我使用它来攻击打开和关闭的事件,并在xaml中放置一个覆盖整个屏幕的边框,并且处理是通过这些事件的可见性。

    <Border Name="UIBlock" Grid.Row="0" Grid.RowSpan="3" Background="#AAFFFFFF" Visibility="Collapsed">
    </Border>

请记住在弹出窗口之前放置此边框

答案 2 :(得分:0)

我使用下面的代码制作了一个小弹出窗口。请试试这个。

<Grid Background="Black" Opacity="0.7"  Visibility="Collapsed" x:Name="gdalert" Height="{Binding Height, ElementName=gdfullpage}" Width="{Binding Width, ElementName=gdfullpage}">
            <Popup x:Name="settingpopup"  Width="350" Grid.Row="1"  HorizontalAlignment="Center" VerticalAlignment="Center">
                <Border x:Name="settingbdrmain"  Grid.Row="1"  BorderThickness="0"  Width="350"  CornerRadius="15" >
                    <Grid x:Name="gdsubshape" Margin="0,10,0,10">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <TextBlock Margin="0,0,0,0" Grid.Row="0" x:Name="dddf" FontSize="20" Text="" HorizontalAlignment="Center" TextAlignment="Center"  FontFamily="Arial" FontWeight="Bold" TextWrapping="Wrap" ></TextBlock>
<TextBlock x:Name="txtsettingalert"  Text="" FontSize="20" TextAlignment="Center" Width="300" FontFamily="Arial"   TextWrapping="Wrap"  Foreground="Black" Grid.Row="1" ></TextBlock>
                        <Border x:Name="settingbdr" Width="350" Grid.Row="2" Height="1" Background="Red" BorderBrush="Black" >
                        </Border>
                        <Grid x:Name="btnpanel" Grid.Row="3" Height="60">
                            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                 <ColumnDefinition Width="Auto">/ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Button x:Name="settingok"   Grid.Column="0"  Height="50"  HorizontalAlignment="Left"VerticalAlignment="Center" MinHeight="20"  Width="170" Content="OK" FontSize="24" Foreground="Green" ></Button>
                            <Border  x:Name="settingsubbdr"  Grid.Column="1" BorderBrush="Green" Height="Auto" Width="1" ></Border>
                            <Button x:Name="sl" Grid.Column="2"  Height="50"  HorizontalAlignment="Right" VerticalAlignment="Center" MinHeight="20"  Width="170" Content="Cancel" FontSize="24" Foreground="Green" ></Button>
                        </Grid>
                    </Grid>
                </Border>
            </Popup>

要打开使用: - popname.IsOpen = true; gdalert.Visibility = Visibility.Visible;

关闭popname.IsOpen = false; gdalert.Visibility = Visibility.Collapse;

相关问题