AppBar.Closed event

Applies to Windows and Windows Phone

Occurs when the AppBar changes from visible to hidden.

Syntax


public event EventHandler<object> Closed


<AppBar Closed="eventhandler"/>

Event information

DelegateSystem.EventHandler<Object> [.NET] | Windows.Foundation.EventHandler<Object> [C++]

Remarks

You can respond to the app bar being dismissed by handling the Closed event.

Examples

This Windows 8 example shows how to handle the Opened and Closed events. When the app bar is opened, the WebView is replaced with a WebViewBrush. When the app bar is dismissed the WebViewBrush is replaced with the WebView. The button in the app bar refreshes the web page and programmatically dismisses the app bar.

Note  This example applies only to apps compiled for Windows 8 (even when running on Windows 8.1). Windows 8.1 introduces changes to the WebView control that fix the issue addressed by this example.


<Page
    x:Class="AppBarSample.WebViewPage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AppBarSample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    
    <Page.BottomAppBar>
        <AppBar x:Name="bottomAppBar" 
                Opened="AppBar_Opened" Closed="AppBar_Closed">
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Style="{StaticResource RefreshAppBarButtonStyle}"
                            Click="Refresh_Click"/>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Border BorderBrush="Gray" BorderThickness="2" Margin="100,20,100,20">
            <Grid>
                <WebView x:Name="contentView" Source="http://www.contoso.com"/>
                <Rectangle x:Name="contentViewRect"/>
            </Grid>
        </Border>
    </Grid>
</Page>



private void AppBar_Opened(object sender, object e)
{
    WebViewBrush wvb = new WebViewBrush();
    wvb.SourceName = "contentView";
    wvb.Redraw();
    contentViewRect.Fill = wvb;
    contentView.Visibility = Windows.UI.Xaml.Visibility.Collapsed;     
}

private void AppBar_Closed(object sender, object e)
{
    contentView.Visibility = Windows.UI.Xaml.Visibility.Visible;
    contentViewRect.Fill = new SolidColorBrush(Windows.UI.Colors.Transparent);
}

private void Refresh_Click(object sender, RoutedEventArgs e)
{
    contentView.Navigate(new Uri("http://www.contoso.com"));
    bottomAppBar.IsOpen = false;
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

AppBar
Quickstart: Adding app bars

 

 

Show:
© 2014 Microsoft