locked
Windows store app c# - AppBarButton.flyout RRS feed

  • Question

  • I am wondering if there is any possible solution for programmatically fill AppBarButton flyout? I need this to do somehow.

    I already tried to find it on web, but I was unsuccessful.

    For an example, I have hardcoded flyout, but how can I add another Item?

    <AppBarButton x:Name="btmBarReaded" Label="Readed status" Visibility="Collapsed" >
                    <AppBarButton.Flyout>
                        <MenuFlyout>
                            <MenuFlyoutItem x:Uid="markReaded" x:Name="markReaded" Click="MenuFlyoutItem_Click" />
                            <MenuFlyoutItem x:Uid="markUnReaded" x:Name="markUnReaded" Click="MenuFlyoutItem_Click" />
                        </MenuFlyout>
                    </AppBarButton.Flyout>
                </AppBarButton>

    Tuesday, January 21, 2014 9:34 AM

Answers

  • here is a sample how to do: http://sdrv.ms/1dQ4BMP

    i think its easier to use the sample then then getting the flyout that is already attached in xaml; i tried this code:

    private void btmBarReaded_Click(object sender, RoutedEventArgs e)
            {
                MenuFlyout flyout = (MenuFlyout)MenuFlyout.GetAttachedFlyout((AppBarButton)sender);
                flyout.Items.Add(new MenuFlyoutItem { Text = "little text" });
            }

    but it doesnt return me an flyout. think its not loaded yet...


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#


    • Edited by Dave SmitsMVP Tuesday, January 21, 2014 10:05 AM
    • Marked as answer by Klemzy2013 Tuesday, January 21, 2014 10:48 AM
    Tuesday, January 21, 2014 10:04 AM

All replies

  • here is a sample how to do: http://sdrv.ms/1dQ4BMP

    i think its easier to use the sample then then getting the flyout that is already attached in xaml; i tried this code:

    private void btmBarReaded_Click(object sender, RoutedEventArgs e)
            {
                MenuFlyout flyout = (MenuFlyout)MenuFlyout.GetAttachedFlyout((AppBarButton)sender);
                flyout.Items.Add(new MenuFlyoutItem { Text = "little text" });
            }

    but it doesnt return me an flyout. think its not loaded yet...


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#


    • Edited by Dave SmitsMVP Tuesday, January 21, 2014 10:05 AM
    • Marked as answer by Klemzy2013 Tuesday, January 21, 2014 10:48 AM
    Tuesday, January 21, 2014 10:04 AM
  • here is a sample how to do: http://sdrv.ms/1dQ4BMP

    i think its easier to use the sample then then getting the flyout that is already attached in xaml; i tried this code:

    private void btmBarReaded_Click(object sender, RoutedEventArgs e)
            {
                MenuFlyout flyout = (MenuFlyout)MenuFlyout.GetAttachedFlyout((AppBarButton)sender);
                flyout.Items.Add(new MenuFlyoutItem { Text = "little text" });
            }

    but it doesnt return me an flyout. think its not loaded yet...


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#


    Thanks, so far so good. I will try it out. Do you maybe know if is possible to do this with binding?
    Tuesday, January 21, 2014 10:15 AM
  • no. the MenuFlyout isnt bindable. You can do something with attached properties probally to build it

    Tuesday, January 21, 2014 10:29 AM
  • look here : http://sdrv.ms/1ehn1Fy this one is solved with something that works with bindings.. it isnt perfect but maybe nice starting point (doesnt support observablecollection for example)

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, January 21, 2014 10:38 AM