0

このコードのタグを次のページに渡す必要がありますが、アクセスする方法がわかりません。誰かがこれを手伝ってくれますか。

コード:

 <ListBox x:Name="AgendaList" Width="450" Height="520" Margin="10" SelectionChanged="event_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image  Width="100" Stretch="Uniform" HorizontalAlignment="Center" Source="/SuperAgenda;component/Images/calendar.jpg" />
                            <TextBlock  Text="{Binding Title_}" Tag="{Binding EventId_}" />

                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

ボタンを使用して送信しているため、タグデータを取得してボタンで次のページに送信する方法を知る必要があります。私のボタンは次のようになりますが、データは送信されません:

private void viewEvent_Click(object sender, RoutedEventArgs e)
    {



        string uri = String.Format("/Views/Event_View/Event_View.xaml?id={0}", clickedLink.Tag);
        NavigationService.Navigate(new Uri(uri, UriKind.Relative));

    }

どんな助けでもいいでしょうありがとう。

4

3 に答える 3

0

バインドされたコントロールにはオブジェクトのすべてのプロパティが含まれているためTag、ここでプロパティを使用する必要はありません。DataTemplateを使用しDataContextてオブジェクトを取得します。Tapにイベントを追加StackPanelしますDataTemplate(ユーザーが画像またはテキストをタップできるようにします):

private void StackPanel_Tap( object sender, GestureEventArgs e ) {
    int eventid = (( sender as StackPanel ).DataContext as MyObject).EventId_;

    string uri = String.Format("/Views/Event_View/Event_View.xaml?id={0}", eventid);
    NavigationService.Navigate(new Uri(uri, UriKind.Relative));
}

次にNavigationContext、受取人の回答を使用して、受信ページで値を取得します。

于 2013-01-03T14:41:12.340 に答える
0

実際、ページ間でデータを転送するには、PhoneApplicationService クラスを使用する必要があります。

 PhoneApplicationService.Current.State["field"] = someField;

ボタンのタップ/クリックイベントで。

次に、次のページでキャストを使用してその値を取得します

someField = (fieldType)PhoneApplicationService.Current.State["field"];

それはあなたが望むものですか?

于 2013-01-03T12:32:06.457 に答える
0

ナビゲートしたページのNavigation Contextプロパティを使用するだけです。

if (this.NavigationContext.QueryString.ContainsKey("ProductId"))
{
    productID = this.NavigationContext.QueryString["ProductId"];
}
else
{
    productID = App.Current.Resources["FeaturedProductID"].ToString();
}
于 2013-01-03T12:33:49.960 に答える