AppBar.Opened event

Applies to Windows and Windows Phone

Occurs when the AppBar changes from hidden to visible.

Syntax

Public Event Opened As EventHandler(Of Object)

<AppBar Opened="eventhandler"/>

Event information

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

Remarks

You can respond to the app bar being opened by handling the Opened 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 Sub AppBar_Opened(sender As Object, e As Object) Handles BottomAppBar.Opened
    Dim wvb As New WebViewBrush()
    wvb.SourceName = "contentView"
    wvb.Redraw()
    contentViewRect.Fill = wvb
    contentView.Visibility = Windows.UI.Xaml.Visibility.Collapsed
End Sub

Private Sub AppBar_Closed(sender As Object, e As Object) Handles BottomAppBar.Closed
    contentView.Visibility = Windows.UI.Xaml.Visibility.Visible
    contentViewRect.Fill = New SolidColorBrush(Windows.UI.Colors.Transparent)
End Sub

Private Sub Refresh_Click(sender As Object, e As RoutedEventArgs)
    contentView.Navigate(New Uri("http://www.contoso.com"))
    bottomAppBar.IsOpen = False
End Sub

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. All rights reserved.