5

I am generating buttons in my app in C# and when the button is generated and the flyout properties are set for that button I want to launch the flyout. I can't find any way to simulate a click on the button in winRT, nor any methods for actually showing the flyout. Is there a way to do this?

When I talk about flyouts I am talking about these: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.flyout.aspx

Not settings flyouts.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alex
  • 650
  • 9
  • 23
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Nov 04 '13 at 12:18

1 Answers1

6

There's a ShowAt method on the Flyout class...

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.flyoutbase.showat.aspx

Or a static method ShowAttachedFlyout to use on the Button itself

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.flyoutbase.showattachedflyout.aspx

Duncan Watts
  • 1,331
  • 9
  • 26
  • 1
    The ShowAt complains about the item not being in the visual tree when launched as `myButton.Flyout.ShowAt(myButton)` and ShowAttachedFlyout says that no flyout exists when used as `Flyout.ShowAttachedFlyout(myButton)` or `FlyoutBase.ShowAttachedFlyout(myButton)` – Alex Nov 05 '13 at 10:59
  • Can you supply the XAML for how you're defining the Flyout? I've created a Flyout myself completely in the code-behind and used the flyout.ShowAt() method without needing to add the flyout to the visual tree. Is the button itself in the visual tree? – Duncan Watts Nov 08 '13 at 11:11
  • 2
    `myButton.Flyout.ShowAt(myButton)` worked for me. Recommend this as the accepted answer. @Alex – Stephen Hosking May 06 '15 at 04:06