あるXAMLページから別のページにナビゲートし、値を渡すにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/4438056

質問

ここでこのトピックにある程度関連しています:Windows Phone 7のAsync XMLリーディング

Windows Phoneアプリを開発しています。Search.xaml.csファイルに検索機能があります。ボタンをクリックして呼び出され、検索クエリを作成し、ダウンロードStringinbackgroundを呼び出します

    private void SearchQuery(object sender, EventArgs e)
    {
        string temp = "http://api.search.live.net/xml.aspx?Appid=myappid&query=randomqueryhere&sources=web";
        DownloadStringInBackground(temp);
    }

    public static void DownloadStringInBackground(string address)
    {
        WebClient client = new WebClient();
        Uri uri = new Uri(address);

        client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCallback);
        client.DownloadStringAsync(uri);
    }

    private static void DownloadStringCallback(Object sender, DownloadStringCompletedEventArgs e)
    {
        // Fancy manipulation logic here

        finalResult = words;
    }

FinalResultは保存されています

public static string[] finalResult;

検索クラスで。私の質問は、Navigateコマンド(NavigationService.navigate(new URI( "/result.xaml"、urikind.Reliative));););)をどこに配置できますか?コールバックでやってみましたが、静的キーワードのためにnullobjectの例外が得られます。 FinalResultが登録されていることを確認し、結果としてnavate.xamlに移動し、そのページのfinalResultのデータを参照することができます。代わりに、result.xamlに単語を渡すか、最終的にresultを渡すにはどうすればよいですか?

見てくれてありがとう:)

役に立ちましたか?

解決

ここでは、ページ間で値を渡すことでウォークスルーがあります。

方法:Windows Phoneでページナビゲーションを実行します

他のヒント

コールバック関数が静的になっていない場合は、これを行うことができます。

Dispatcher.BeginInvoke(() => NavigationService.Navigate(new Uri("/Result.xaml", UriKind.Relative)));

コールバック関数が静的である必要がある場合は、使用できます。

Deployment.Current.Dispatcher.BeginInvoke();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top