TitleBar.PaneToggleRequested Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when the pane toggle button is invoked.
// Register
event_token PaneToggleRequested(TypedEventHandler<TitleBar, IInspectable const&> const& handler) const;
// Revoke with event_token
void PaneToggleRequested(event_token const* cookie) const;
// Revoke with event_revoker
TitleBar::PaneToggleRequested_revoker PaneToggleRequested(auto_revoke_t, TypedEventHandler<TitleBar, IInspectable const&> const& handler) const;
public event TypedEventHandler<TitleBar,object> PaneToggleRequested;
function onPaneToggleRequested(eventArgs) { /* Your code */ }
titleBar.addEventListener("panetogglerequested", onPaneToggleRequested);
titleBar.removeEventListener("panetogglerequested", onPaneToggleRequested);
- or -
titleBar.onpanetogglerequested = onPaneToggleRequested;
Public Custom Event PaneToggleRequested As TypedEventHandler(Of TitleBar, Object)
Event Type
TypedEventHandler<TitleBar,IInspectable>
Examples
<!-- MainWindow.xaml -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TitleBar Title="My App"
IsPaneToggleButtonVisible="True"
PaneToggleRequested="TitleBar_PaneToggleRequested">
</TitleBar>
<NavigationView x:Name="RootNavigationView" Grid.Row="1"
IsPaneToggleButtonVisible="False">
<Frame x:Name="RootFrame" />
</NavigationView>
</Grid>
// MainWindow.xaml.cs
private void TitleBar_PaneToggleRequested(TitleBar sender, object args)
{
RootNavigationView.IsPaneOpen = !RootNavigationView.IsPaneOpen;
}
Remarks
When you use the TitleBar control with a NavigationView control, you should replace the navigation view's pane toggle button with the title bar's pane toggle button.
We recommend that you:
- Hide the pane toggle button in the
NavigationView
control.<NavigationView IsPaneToggleButtonVisible="False">
- Show the pane toggle button in the
TitleBar
.<TitleBar IsPaneToggleButtonVisible="True">
- Handle this event to toggle the value for the NavigationPane.IsPaneOpen property.
There is no inherent connection between the TitleBar
's pane toggle button and the NavigationView
. The TitleBar
button simply raises this event to let you provide code to toggle the NavigationView
's pane.