Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display a flyout from a XAML UserControl #1620

Closed
rcalado opened this issue Oct 29, 2014 · 7 comments
Closed

How to display a flyout from a XAML UserControl #1620

rcalado opened this issue Oct 29, 2014 · 7 comments

Comments

@rcalado
Copy link

rcalado commented Oct 29, 2014

I am using MahApps Version 0.14.0.0
Is there a way to get the FlyoutsControl to work from within a xaml UserControl?

Take your MetroDemo Sample UI for an example.....you call usercontrols for each of your tab screens. (which is exactly what we do). The main functionality is contained within each exampleView Usercontrol. So getting the Flyout to work from here would be fantastic since the usercontrol is already "wrapped" by the MetroWindow.

 <Controls:MetroAnimatedSingleRowTabControl Grid.Row="1" x:Name="MainTabControl">
                <TabItem Header="buttons">
                    <exampleViews:ButtonsExample DataContext="{Binding}" />
                </TabItem>
                <TabItem Header="text">
                    <exampleViews:TextExamples DataContext="{Binding}" />
                </TabItem>
</TabControl>

If anyone has come up with a solution or even a hack to get the flyout control to work from the UserControl please paste a sample of what you did to get it to work.

@andySF
Copy link

andySF commented Oct 30, 2014

You could put your flyout in your window then find it and display it.

    Window parentWindow = Window.GetWindow(this);
    object obj = parentWindow.FindName("mainFlyout");
    Flyout flyout = (Flyout) obj;  
    flyout.Content = new SomeFlyOutUserControl();
    flyout.IsOpen = !flyout.IsOpen;

@flagbug
Copy link
Member

flagbug commented Dec 1, 2014

The flyouts heavily depend on the hosting MetroWindow for various things, so this isn't possible currently

@rcalado
Copy link
Author

rcalado commented Feb 6, 2015

Just wanted to comment back that I was able to get this to work following AndySF's solution.
Created the mainFlyout control on the "mainwindow" control and was able to launch the flyout from within the tab user control with AndSF's code.

@maciz84
Copy link

maciz84 commented Oct 26, 2016

I still think this should be a feature out of the box the need to use this control in a usercontrol is very common

@barishamil
Copy link

barishamil commented Jan 23, 2018

There should be an option to make Flyout behave like it's defined in the window

@CDDFERREIRA
Copy link

I understand the solution provided to access the Flyout on the UserControl form the Parent.
However, how can I do this if I am using the MVVM design?

@mxsoftware
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants