在主窗口顶部有一个自定义弹出窗口使主窗口不会到达最顶层

时间:2017-06-28 15:05:21

标签: c# .net wpf xaml prism

我使用了棱镜的InteractionRequestTrigger和Popupwindowaction来提升自定义弹出窗口,它不是一个模型窗口,但是在主窗口顶部有一个自定义弹出窗口,当非模型弹出窗口在那里时,主窗口不会显示为主窗口窗口被用户点击,不知道如何解决这个问题?

MainWindowView

    <Window x:Class="UsingPopupWindowAction.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:prism="http://prismlibrary.com/"
        xmlns:views="clr-namespace:UsingPopupWindowAction.Views"
        prism:ViewModelLocator.AutoWireViewModel="True"
        Title="{Binding Title}" Height="350" Width="500">
    <i:Interaction.Triggers>
        <prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest}">
            <prism:PopupWindowAction IsModal="False" CenterOverAssociatedObject="True" >
                <prism:PopupWindowAction.WindowContent>
                    <views:CustomePopup/>
                </prism:PopupWindowAction.WindowContent>
            </prism:PopupWindowAction>
        </prism:InteractionRequestTrigger>
    </i:Interaction.Triggers>
    <StackPanel>
        <Button Margin="5" Content="Raise Custome Popup" Command="{Binding NotificationCommand}" />

        <TextBlock Text="{Binding Title}" Margin="25" HorizontalAlignment="Center" FontSize="24" />
    </StackPanel>
</Window>

MainWindowViewModel

namespace UsingPopupWindowAction.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        private string _title = "MainWindow";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        public InteractionRequest<INotification> NotificationRequest { get; set; }
        public DelegateCommand NotificationCommand { get; set; }

        public MainWindowViewModel()
        {
            NotificationRequest = new InteractionRequest<INotification>();
            NotificationCommand = new DelegateCommand(RaiseNotification);


        }

        void RaiseNotification()
        {
            NotificationRequest.Raise(new Notification { Content = "Notification Message", Title = "Custome Popup" }, r => Title = "Notified");
        }

    }
}

CustomePopupView

<UserControl x:Class="UsingPopupWindowAction.Views.CustomePopup"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:UsingPopupWindowAction.Views"
             Height="400" Width="400">
    <Grid>
        <TextBlock Text="Please click mainwindow to get it to top of me" HorizontalAlignment="Center" VerticalAlignment="Center" />
    </Grid>
</UserControl>

0 个答案:

没有答案