如何在弹出窗口时禁用页面

问题描述 投票:0回答:2

我试图在页面上显示弹出窗口。所需的行为是将页面放在后台,弹出窗口将显示在该页面上。显示弹出窗口时,我仍然可以与后台页面进行交互。但是我需要禁用后台页面。

<Grid>
    <Grid>
        <Pivot IsEnabled="{Binding IsPopUpOpen , Converter={StaticResource BooleanInversionConverter}}">
        </Pivot>
    </Grid>

    <Popup Name="Popup" IsOpen="{Binding IsPopUpOpen}" VerticalAlignment="Center">
        <TextBox Foreground="Black" FontSize="28" FontWeight="Normal" BorderBrush="Black" BorderThickness="2" HorizontalAlignment="Left" Width="440"/>
    </Popup>

</Grid>

当我运行此代码时,我得到一个例外:

System.InvalidOperationException未处理消息:System.Windows.ni.dll中发生未处理的类型“System.InvalidOperationException”异常附加信息:无法解析TargetName Img。

让我知道如何使用MVVM方法禁用数据透视。

xaml windows-phone-8 popup popupwindow
2个回答
0
投票

Juste将弹出窗口置于所有其他控件之上。例:

<grid>
  <yourxaml>
</grid>
<popup horizontalAlignement="Stretch" verticalignementAlignement="Stretch"></popup>

在这里,用户无法与应用程序的其他部分进行交互,因为您的控件弹出窗口优先于其他部分。


0
投票

您应该能够订阅Opened和Closed事件获取Window并禁用Window本身。我有一个子类,所以我选择覆盖,因为我想要一个可拖动的Popup。以下对我有用。

        protected override void OnOpened(EventArgs e)
        {
            base.OnOpened(e);

            var parentWindow = Window.GetWindow(this);

            parentWindow.IsEnabled = false;
        }

        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            var parentWindow = Window.GetWindow(this);

            parentWindow.IsEnabled = true;
        }
© www.soinside.com 2019 - 2024. All rights reserved.