Departure behind the application panel
If you want your app to expand to full screen (including status bar and app bar), you need to do the following:
var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
applicationView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
Then, if you want to have a popup in your app bar or elsewhere in your app, they'll appear behind the app bar:
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Icon="Preview" Label="Preview">
<AppBarButton.Flyout>
<MenuFlyout>
<MenuFlyoutItem Text="Fit width" />
<MenuFlyoutItem Text="Fit height" />
<MenuFlyoutItem Text="Fit page" />
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
</CommandBar>
</Page.BottomAppBar>
Result:
Same as list item popups. They will be displayed behind the app bar:
How do I display pop-ups over the app bar?
+3
source to share
1 answer
I cannot solve my problem (or someone who can help). So I did it like this, in case it might help someone:
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Icon="Preview" Label="Preview">
<AppBarButton.Flyout>
<MenuFlyout Opened="MenuFlyout_Opened" Closed="MenuFlyout_Closed">
<MenuFlyoutItem Text="Fit width" />
<MenuFlyoutItem Text="Fit height" />
<MenuFlyoutItem Text="Fit page" />
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
</CommandBar>
</Page.BottomAppBar>
private void MenuFlyout_Opened(object sender, object e)
{
BottomAppBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
}
private void MenuFlyout_Closed(object sender, object e)
{
BottomAppBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
Now my popup appears completely as there is no more application bar. For mvvm list view items, I did this in behavior:
<DataTemplate x:Key="MvvmItemTemplate">
<Grid>
<i:Interaction.Behaviors>
<icore:EventTriggerBehavior EventName="Holding">
<local:OpenFlyoutAction />
</icore:EventTriggerBehavior>
</i:Interaction.Behaviors>
<FlyoutBase.AttachedFlyout>
<MenuFlyout>
<MenuFlyoutItem ..... Command="{Binding MarkRead}" />
<MenuFlyoutItem ..... Command="{Binding MarkUnread}" />
<MenuFlyoutItem ..... Command="{Binding PinToStart}" />
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
</Grid>
</DataTemplate>
public class OpenFlyoutAction : DependencyObject, IAction
{
public object Execute(object sender, object parameter)
{
// Show menu
FlyoutBase.ShowAttachedFlyout((FrameworkElement)sender);
// sometimes the appbar is stuck behind the appbar, so hide the appbar
(sender as FrameworkElement).GetFirstAncestorOfType<Page>().BottomAppBar.Visibility = Visibility.Collapsed;
// show the appbar again when flyout is closed
var flyout = FlyoutBase.GetAttachedFlyout((FrameworkElement)sender);
EventHandler<object> showBar = null;
showBar = delegate (object s, object e)
{
(sender as FrameworkElement).GetFirstAncestorOfType<Page>().BottomAppBar.Visibility = Visibility.Visible;
// unsubscribe handler:
flyout.Closed -= showBar;
};
flyout.Closed += showBar;
return null;
}
}
+5
source to share