상세 컨텐츠

본문 제목

[xbap] parameter 읽어들이기

WPF

by happynuri 2008. 7. 8. 14:20

본문



xbap에서 parameter를  읽어 들이는 데에는 두가지 방식이 있다.

그 중 오늘은 한가지 방식을 가지고 간단한 예제를 보여 줄것이다.

매우 간단하다.

xbap 프로 젝트를 생성하고

using System.Web;//xbap style
using System.Windows.Interop; //BrowserInteropHelper

xaml에는 간단하게 레이블 하나 생성해서 붙여 놓자.

  <Label x:Name="lblResult" Width="100" Height="30" BorderBrush="Aqua" BorderThickness="1"
Content="파라미터받기전.."/>


page.xaml.cs 단으로 이동한다.

그리고 이 소스를 사용한다.

namespace WPFParamTest
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        public Page1()
        {
            InitializeComponent();
            //url parameters - XBAP style
            NameValueCollection params_BIH = GetQueryStringParameters(BrowserInteropHelper.Source);
            if (params_BIH.Count != 0)
            {
                //lblResult.Content = params_BIH[0].ToString();//인덱스로도 된다.
               lblResult.Content = params_BIH["a"] .ToString();//이름으로도 된다.
            }
        }
     }
}

그리고 배포 후 테스트 한다.

http://xxxxxxxxxx/xxxxxx/xxxx/WPFParamTest.xbap

결과

사용자 삽입 이미지

http://xxxxxxxxxx/xxxxxx/xxxx/WPFParamTest.xbap?a=받았다 의 결과

사용자 삽입 이미지



by happynuri

http://forums.msdn.microsoft.com/ko-KR/wpf/thread/a8da0b34-a16d-4923-acf4-84dceeb1675a/

관련글 더보기

댓글 영역