是否有与 UWP 的 SplitView 汉堡菜单等效的 WPF?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33104030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a WPF-equivalent to UWP's SplitView Hamburger Menu?
提问by BCA
The Hamburger-style SplitView controlin the Universal Windows Platform is perfect, IMO. However, my project has a WPF frontend.
通用 Windows 平台中的汉堡式 SplitView 控件是完美的,IMO。但是,我的项目有一个 WPF 前端。
Does anybody know of a WPF equivalent to this (preferably open source)?
有人知道与此等效的 WPF(最好是开源的)吗?
回答by tofutim
Another implementation to study is https://github.com/alicanerdogan/HamburgerMenu
回答by igorushi
回答by Muster Station
Using the GridSplittercontrol and a StoryBoard, you can set this up quite easily. You may need to tweak this code a bit to make it appear like the hamburger, but this should get you well on your way.
使用GridSplitter控件和StoryBoard,您可以很容易地进行设置。您可能需要稍微调整此代码以使其看起来像汉堡包,但这应该会让您顺利进行。
<UserControl
x:Class="Namespace.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="mainPage">
<Grid>
<Grid.Resources>
<Storyboard x:Name="CloseLeft">
<DoubleAnimation x:Name="animNavLinksClose"
Storyboard.TargetName="mainPage" Storyboard.TargetProperty="NavLinksWidth"
To="0.0" Duration="00:00:00.2" />
</Storyboard>
<Storyboard x:Name="OpenLeft">
<DoubleAnimation x:Name="animNavLinksOpen"
Storyboard.TargetName="mainPage" Storyboard.TargetProperty="NavLinksWidth"
From="0" To="170" Duration="00:00:00.2" />
</Storyboard>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170" x:Name="NavLinksColumn" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid x:Name="grdNavLinks" Grid.Column="0">
<!-- Navigation Buttons -->
</Grid>
<GridSplitter x:Name="spltNavLinks" Grid.Column="1" />
<Grid x:Name="contentSection" Grid.Column="2">
<!-- Content or Frame -->
</Grid>
</Grid>
</UserControl>
Then you can call your storyboard from the code-behind like this
然后你可以像这样从代码隐藏中调用你的故事板
// Begin Opening Animation
OpenLeft.Begin();
// Begin Closing Animation
CloseLeft.Begin();


