是否可以在 Silverlight 的子窗口内打开对话框窗口?

发布于 2024-10-20 08:05:02 字数 1279 浏览 2 评论 0原文

我需要将 OpenDialog 窗口置于 Silverlight 应用程序的浏览器窗口内。我想知道是否可能。非常感谢任何帮助!

下面是我必须打开子窗口和 OpenDialog 的代码:

 private void openChildWindow_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        Add_ChildWindow ap = new Add_ChildWindow();
        ap.Show();

          OpenFileDialog openFileDialog1 = new OpenFileDialog();
        // Set filter options and filter index.
        openFileDialog1.Filter = "Packages (*.sprj)|*.sprj|Packages (*.sprj)|*.sprj";
        openFileDialog1.FilterIndex = 1;

        openFileDialog1.Multiselect = true;

        // Call the ShowDialog method to show the dialog box.
        bool? userClickedOK = openFileDialog1.ShowDialog();

        // Process input if the user clicked OK.
        if (userClickedOK == true)
        {
            // Open the selected file to read.
            //textBox1.Text = openFileDialog1.File.Name;
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
            {
                // Read the first line from the file and write it the textbox.
               // tbResults.Text = reader.ReadLine();
            }
            fileStream.Close();
        }
    }

I need to have OpenDialog window being inside browser window of Silverlight application. I am wondering if it possible. Any help is highly appreciated!

Below is the code I have to open child window and OpenDialog:

 private void openChildWindow_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        Add_ChildWindow ap = new Add_ChildWindow();
        ap.Show();

          OpenFileDialog openFileDialog1 = new OpenFileDialog();
        // Set filter options and filter index.
        openFileDialog1.Filter = "Packages (*.sprj)|*.sprj|Packages (*.sprj)|*.sprj";
        openFileDialog1.FilterIndex = 1;

        openFileDialog1.Multiselect = true;

        // Call the ShowDialog method to show the dialog box.
        bool? userClickedOK = openFileDialog1.ShowDialog();

        // Process input if the user clicked OK.
        if (userClickedOK == true)
        {
            // Open the selected file to read.
            //textBox1.Text = openFileDialog1.File.Name;
            System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

            using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
            {
                // Read the first line from the file and write it the textbox.
               // tbResults.Text = reader.ReadLine();
            }
            fileStream.Close();
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-10-27 08:05:02

打开对话框窗口是一个系统窗口。我相信 Silverlight 沙箱必须使用系统打开对话框。

换句话说,我认为这是不可能的。

An Open Dialog window is a system window. Silverlight being sandboxed has to use the system open dialog I believe.

In other words, I don't think this is possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文