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

Xaml 如何在显示弹出窗口时禁用页面,xaml,windows-phone-8,popup,popupwindow,Xaml,Windows Phone 8,Popup,Popupwindow,我试图在页面上显示一个弹出窗口。理想的行为是将页面置于后台,弹出窗口将显示在该页面上。当弹出窗口显示时,我仍然能够与背景页面进行交互。但是我需要禁用背景页面 <Grid> <Grid> <Pivot IsEnabled="{Binding IsPopUpOpen , Converter={StaticResource BooleanInversionConverter}}"> </Pivot> <

我试图在页面上显示一个弹出窗口。理想的行为是将页面置于后台,弹出窗口将显示在该页面上。当弹出窗口显示时,我仍然能够与背景页面进行交互。但是我需要禁用背景页面

<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.InvalidOperationException”类型的异常 System.Windows.ni.dll其他信息:无法解析 TargetName Img


让我知道如何使用MVVM方法禁用pivot。

只需将弹出窗口置于所有其他控件之上即可。 例如:



在这里,用户不能与应用程序的其他部分进行交互,因为您的控件弹出窗口高于所有其他部分。

您应该能够订阅打开和关闭的事件,获取窗口并禁用窗口本身。我有一个子类,所以我选择重写,因为我想要一个可拖动的弹出窗口。下面是我的作品

        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;
        }

弹出窗口的背景将创建一个覆盖。我希望页面可见。弹出窗口通常不会隐藏整个屏幕。哦,你想显示弹出窗口而不在后台显示应用程序吗?真的很奇怪,但是为什么不创建一个通用页面来显示您的消息呢?w页
        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;
        }