2017-11-22 10 views
0

私はListViewを持っています、その個々の各ListViewItemは同じ名前のMenuFlyOutItemを持っています。しかし、ListViewItemにあるMenuFlyOutItemのその名前をクリックすると、ListViewItemのMenuFlyouItemからその選択された項目と共に次のページに移動する必要があります。 添付したファイルを見つけてください。MenuFlyoutItemの選択した項目値を別のページにバインドするにはどうすればいいですか?

XAMLコード:MenuFlyoutItem_ClickInspesため

<Button Grid.Row="0" Margin="0,0,15,0" Grid.RowSpan="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Blue" Height="50" Width="15"> 
       <Button.Flyout> 
        <MenuFlyout> 
         <MenuFlyoutItem > 
          <MenuFlyoutItem.Template> 
           <ControlTemplate TargetType="MenuFlyoutItem"> 
            <StackPanel Orientation="Horizontal"> 
             <SymbolIcon Margin="10,10,10,10" Symbol="Map"></SymbolIcon> 
             <TextBlock Margin="10,10,10,10" Text="Geo Tag" FontSize="20" ></TextBlock> 
            </StackPanel> 
           </ControlTemplate> 
          </MenuFlyoutItem.Template> 
         </MenuFlyoutItem> 
         <MenuFlyoutItem Text="Create Notification" Foreground="Black" FontSize="20" Background="Transparent" Click="MenuFlyoutItem_Click"></MenuFlyoutItem> 
         <MenuFlyoutItem Text="Statistics" Foreground="Black" FontSize="20" Background="Transparent"></MenuFlyoutItem> 
         <MenuFlyoutItem Text="History" Foreground="Black" FontSize="20" Background="Transparent"></MenuFlyoutItem> 
         <MenuFlyoutItem Text="Orders" Foreground="Black" FontSize="20" Background="Transparent"></MenuFlyoutItem> 
            <MenuFlyoutItem Text="Inspection Checklist" Foreground="Black" FontSize="20" Background="Transparent" CommandParameter="{Binding Path=InspectionCommand, Mode=TwoWay}" Click="MenuFlyoutItem_ClickInspes"> 
          <!--<I:Interaction.Behaviors> 
           <core:EventTriggerBehavior EventName="Tapped"> 
            <core:InvokeCommandAction Command="{Binding Path=InspectionCommand, Mode=TwoWay}"></core:InvokeCommandAction> 
           </core:EventTriggerBehavior> 
          </I:Interaction.Behaviors>--> 
         </MenuFlyoutItem> 
         <MenuFlyoutItem Text="Maintainence Plan" Foreground="Black" FontSize="20" Background="Transparent"></MenuFlyoutItem> 
        </MenuFlyout> 
       </Button.Flyout> 
      </Button> 

Xaml.csコード:

private void MenuFlyoutItem_ClickInspes(object sender, RoutedEventArgs e) 
    { 
     this.Frame.Navigate(typeof(InpectionCheckListEquipmentPage)); 
    } 

答えて

0

がどのように別のページにMenuFlyoutItemの選択項目の値をバインドするには?

Navigateメソッドでは、ナビゲーションのターゲットによって解釈されるパラメータを渡すことができます。方法の詳細はPass information between pagesを参照してください。たとえば、次のように

private void MenuFlyoutItem_ClickInspes(object sender, RoutedEventArgs e) 
{ 
    MenuFlyoutItem currentitem = sender as MenuFlyoutItem; 
    this.Frame.Navigate(typeof(InpectionCheckListEquipmentPage),currentitem.Text); 
} 

そしてInpectionCheckListEquipmentPage上:

protected override void OnNavigatedTo(NavigationEventArgs e) 
{ 
    if (e.Parameter is string && !string.IsNullOrWhiteSpace((string)e.Parameter)) 
    { 
     var menuitemvalue = e.Parameter as string; 
    } 
    else 
    { 

    } 
    base.OnNavigatedTo(e); 
} 
関連する問題