使用OpenFileDialog的WPF弹出控件 [英] WPF PopUp Control with OpenFileDialog

查看:77
本文介绍了使用OpenFileDialog的WPF弹出控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在WPF应用程序中使用了带有OpenFileDialog函数的PopUpControl(变量对话框=新的System.Windows.Forms.OpenFileDialog()).

它工作正常,但是:
FileOpenDialog在后台.
而PopUpControl位于前台.
因此,用户看不到OpenFileDialog.

如何将OpenFileDialog放在前台??

THX !!!

Benny

Hi,
I habe in my WPF-App a PopUpControl with a OpenFileDialog function (var dialog = new System.Windows.Forms.OpenFileDialog()).

It works fine, but:
The FileOpenDialog is in the Background.
And the PopUpControl is in the foreground.
Therefore, the User can not see the OpenFileDialog.

How can i put the OpenFileDialogin the foreground???

THX!!!

Benny

推荐答案

我尝试过了,这是我的代码:
XAML文件如下所示:
Well I tried and here is my code for this:
XAML File looks like that:
<Window x:Class="WpfApplication2.Window1"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Window1" Height="300" Width="300" MouseEnter="Window_MouseEnter">
    <Grid>
      <Popup x:Name="PopupTest" AllowsTransparency="True" Opened="PopupTest_Opened" MouseDown="PopupTest_MouseDown">
         <Viewbox VerticalAlignment="Top">
            <TextBlock Text="WWW">

            </TextBlock>
         </Viewbox>
      </Popup>
   </Grid>
</Window>


CS文件如下:


And the cs file is the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;

namespace WpfApplication2
{
   /// <summary>
   /// Interaction logic for Window1.xaml
   /// </summary>
   public partial class Window1 : Window
   {
      public Window1()
      {
         InitializeComponent();
      }

      private void Window_MouseEnter(object sender, MouseEventArgs e)
      {
         PopupTest.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse;
         PopupTest.StaysOpen = false;
         PopupTest.Height = 1000;
         PopupTest.Width = 500;
         PopupTest.IsOpen = true;
      }

      private void PopupTest_Opened(object sender, EventArgs e)
      {
         //var dialog = new OpenFileDialog();
         //dialog.ShowDialog();
      }

      private void PopupTest_MouseDown(object sender, MouseButtonEventArgs e)
      {
         var dialog = new OpenFileDialog();
         dialog.ShowDialog();
      }

   }
}



并且openfile对话框显示在前台:-).



And the openfiledialog is displayed in the foreground :-).


这篇关于使用OpenFileDialog的WPF弹出控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆