0

单击图钉布局中的箭头时如何导航到另一个页面?

App.xaml 页面代码:

<Application.Resources>
        <Style x:Key="MenuItemsStyle" TargetType="sltkit:MenuItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sltkit:MenuItem">
                        <StackPanel>
                            <TextBlock Text="{Binding Name}" 
                                       TextWrapping="Wrap" 
                                       Margin="24,0" 
                                       FontSize="26"/>
                            <TextBlock Text="{Binding Description}" 
                                       TextTrimming="WordEllipsis" 
                                       Margin="24,0" 
                                       FontSize="22"/>
                            <TextBlock Text="{Binding DatetimeAdded}" 
                                       TextTrimming="WordEllipsis" 
                                       Margin="24,0" 
                                       FontSize="22"/>
                            <Image  Source="/MyBuddies;component/Images/decline.png" Height="20" Width="20" Margin="200,0" Stretch="Fill" Name="imgDecline"  >
                            </Image>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MenuStyle" TargetType="sltkit:ContextMenu">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border CornerRadius="8" Margin="24" 
                               BorderBrush="Green" BorderThickness="2">
                            <Border.Background>
                                <LinearGradientBrush 
                                   StartPoint="0.5,0" EndPoint="0.5,1">
                                    <GradientStop Color="White" 
                                                 Offset="0.0"/>
                                    <GradientStop Color="LightBlue" 
                                                 Offset="0.5"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <ItemsPresenter />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>

in mainpage.xaml 

<my:MapItemsControl.ItemTemplate>
                        <DataTemplate>
                         <my:Pushpin
                          Background="Blue"
                           Location="{Binding Location}" Tap="Pushpin_Tap">
                                <sltkit:ContextMenuService.ContextMenu>
                                    <sltkit:ContextMenu IsZoomEnabled="False">
                                        <sltkit:MenuItem Style="{StaticResource MenuItemsStyle}"/>
                                    </sltkit:ContextMenu>
                                </sltkit:ContextMenuService.ContextMenu>
                            </my:Pushpin>
                        </DataTemplate>
                    </my:MapItemsControl.ItemTemplate>
                </my:MapItemsControl>

点击显示描述的图钉。点击时需要在该布局中放置一个箭头,将一些值传递到另一个页面。如何实现这一点?请告诉我...

4

1 回答 1

2

在 App.xaml 中编写一些 UI 代码不是一个好习惯。App.xaml 和 App.xaml.cs 旨在处理应用程序生命周期事件,例如启动、关闭、激活和停用事件,并用于共享一些全局数据。

如果你还想使用,那么在后面的代码中你可以使用下面的代码从 App.xaml 导航到另一个页面

(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/AnotherPage.xaml", UriKind.RelativeOrAbsolute));
于 2012-06-14T11:46:48.037 回答