我有一个ListView,每个ListViewItem都有一个名称相同的MenuFlyOutItem。但是,当我在ListViewItem中的MenuFlyOutItem中单击该名称时,必须导航到下一页以及ListViewItem的MenuFlyouItem中的所选项。 请找到我附上的文件。
XAML代码:
<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>
MenuFlyoutItem_ClickInspes的Xaml.cs代码:
private void MenuFlyoutItem_ClickInspes(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(InpectionCheckListEquipmentPage));
}
答案 0 :(得分: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);
}