AppBar.Closed Event

AppBar 屬性從可見變更為隱藏時發生。

語法


public event EventHandler<object> Closed


<AppBar Closed="eventhandler"/>

事件資訊

委派System.EventHandler<Object> [.NET] | Windows.Foundation.EventHandler<Object> [C++]

備註

您可以藉由處理 Closed 事件來回應要關閉的應用程式列。

範例

本範例示範如何處理 OpenedClosed 事件。當應用程式列開啟時,WebView 會取代為 WebViewBrush。當應用程式列關閉時,WebViewBrush 會取代為 WebView。應用程式列中的按鈕會重新整理網頁並以程式設計方式關閉應用程式列。


<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;
}


需求

最低支援的用戶端

Windows 8

最低支援的伺服器

Windows Server 2012

命名空間

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

中繼資料

Windows.winmd

另請參閱

AppBar
快速入門:加入應用程式列

 

 

顯示:
© 2015 Microsoft