현재 ASP.NET에서와 같이 URL에서 매개 변수를 받아 들일 필요가있는 WPF 응용 프로그램이 있습니다. 나는 이전 게시물을 쳐다 보았으나 진흙처럼 분명하지는 않습니다. 필자는 이미 "게시"섹션을 매개 변수의 승인을 위해 변경했습니다. 다음은 내가 사용하고있는 코드입니다.WPF 응용 프로그램에 쿼리 문자열의 C# 매개 변수를 전달하십시오.
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;
}
}
}
}
내가 가지고 같은 것을 할 필요가
를 사용하여 쿼리 문자열의 다른 매개 변수가되지 않습니다 URL에 원하는 데이터가 있습니까? – BradleyDotNET
또는 ActivationData가 예상 한 것과 다릅니다. 코드가있는 텍스트 상자의 텍스트가 ActivationData [0] URL – BradleyDotNET
@LordTakkera의 쿼리 문자열로 설정됩니다. URL은 http : \\ website.us입니까? DKT_ID = param. 난 정말 WPF 응용 프로그램에서 URL에서 텍스트 상자에이 유일한 매개 변수를 얻으려고 고군분투하고 있습니다. – clerktech