2012-06-14 65 views
0

如何在圖釘佈局中點擊箭頭時導航到另一個頁面?如何在app.xaml.cs頁面中點擊佈局時導航到另一個頁面?

的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> 

自來水圖釘上顯示的說明。需要放置一個箭頭在佈局時,點擊上通過一些數值到另一個page.how以達致這請告訴我...

回答

2

在App.xaml中編寫一些UI代碼不是一個好習慣。 App.xaml和App.xaml.cs旨在處理應用程序生命週期事件,如啓動,關閉,激活和停用事件以及共享某些全局數據。

如果你仍想使用,然後在後面的代碼,你可以使用下面的代碼從App.xaml中

(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/AnotherPage.xaml", UriKind.RelativeOrAbsolute)); 
導航到另一個頁面
相關問題