簡體   English   中英

如何在C#Metro Style應用中選擇彈出菜單項

[英]How to choose flyout menu item in c# metro style app

我想選擇菜單彈出項目的每個項目。 基本上,我想從背后的代碼中選擇一個項目並對其執行功能。

<AppBarButton  x:Name="Resize" Click="resizeop_click"HorizontalAlignment="Left" >
    <AppBarButton.Flyout>
        <MenuFlyout>
            <MenuFlyoutItem Text="1" HorizontalAlignment="Stretch" />
            <MenuFlyoutItem Text="Second command" />
            <MenuFlyoutSeparator />
            <ToggleMenuFlyoutItem Text="Last option" />
        </MenuFlyout>
    </AppBarButton.Flyout>
    <AppBarSeparator>
    </AppBarSeparator>
</AppBarButton>

遵循C#函數

private void resizeop_click(object sender, RoutedEventArgs e)
{
   // Not Working 
   Resize.Flyout.GetValue = "1";
   // How Should i select Each Item in code here?
}

您可以像這樣獲得MenuFlyoutItem:使用索引:

((Resize.Flyout as MenuFlyout).Items[0] as MenuFlyoutItem).Text = "hello world";

此代碼可以將文本從“ 1”設置為“ hello world”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM