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.
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;
The flyouts heavily depend on the hosting MetroWindow for various things, so this isn't possible currently
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.
I still think this should be a feature out of the box the need to use this control in a usercontrol is very common
There should be an option to make Flyout behave like it's defined in the window
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?
Most helpful comment
I still think this should be a feature out of the box the need to use this control in a usercontrol is very common