0

現在、ASP.NET のように URL からパラメーターを受け入れる必要がある WPF アプリケーションがあります。SOに関する以前の投稿を見てきましたが、泥のようにはっきりしているようには見えません。「発行」のセクションも、パラメーターの受け入れのために既に変更しています。以下は私が利用しているコードです:

using System;
using System.Deployment;
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 ViewImageForm;
using System.Windows.Forms.Integration;
using System.Windows.Forms;
using System.Web;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Deployment.Application;

namespace WPFHost
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        private readonly Form1 mainForm = new Form1();

    public Page1()
    {
        InitializeComponent();

        //Create a Windows Forms Host to host a form
        WindowsFormsHost windowsFormsHost = new WindowsFormsHost();

        stackPanel.Width = mainForm.Width;
        stackPanel.Height = mainForm.Height;
        windowsFormsHost.Width = mainForm.Width;
        windowsFormsHost.Height = mainForm.Height;

        mainForm.TopLevel = false;

        windowsFormsHost.Child = mainForm;

        stackPanel.Children.Add(windowsFormsHost);
    }

    private void Page_Loaded(object sender, RoutedEventArgs e)
    {
        if (ApplicationDeployment.IsNetworkDeployed)
        {
        string url =
        AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[
        0];
        string queryString = (new Uri(url)).Query;
        this.textBox1.Text = queryString;
        }
    }
  }
}
4

1 に答える 1