[英]Proper way to add an AutoSuggestBox to Hamburger Navigation?
I'm just starting to learn UWP and xaml. 我刚刚开始学习UWP和xaml。 What is the proper way to add a AutoSuggestBox to the Side Navigation panel?
将AutoSuggestBox添加到“侧面导航”面板的正确方法是什么? (Sorry for the bad code formatting in advance, copy and paste wasn't great)
(对不起,如果代码格式化错误,复制和粘贴效果不好)
My Main.xaml has an AutoSuggestArea that I have set to Visible 我的Main.xaml具有我设置为Visible的AutoSuggestArea
</VisualStateGroup>
<VisualStateGroup x:Name="AutoSuggestGroup">
<VisualState x:Name="AutoSuggestBoxVisible"/>
<VisualState x:Name="AutoSuggestBoxCollapsed">
<VisualState.Setters>
<Setter Target="AutoSuggestArea.Visibility" Value="Visible"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
and in the Grid for the AutoSuggestArea I have defined an AutoSuggestBox 在AutoSuggestArea的网格中,我定义了一个AutoSuggestBox
<Grid x:Name="AutoSuggestArea" Height="44" Grid.Row="3" VerticalAlignment="Center">
<ContentControl x:Name="PaneAutoSuggestBoxPresenter" Content="{TemplateBinding AutoSuggestBox}" HorizontalContentAlignment="Stretch" IsTabStop="False" Margin="16,0,16,0" VerticalContentAlignment="Center"/>
<Button x:Name="PaneAutoSuggestButton" Content="" MinHeight="44" Style="{TemplateBinding PaneToggleButtonStyle}" Visibility="Collapsed" Width="{TemplateBinding CompactPaneLength}"/>
<AutoSuggestBox Width="234" VerticalAlignment="Center"
HorizontalAlignment="Center"
PlaceholderText="Search" Name ="boxS"
QuerySubmitted="AutoSuggestBox_QuerySubmitted"
TextChanged="AutoSuggestBox_TextChanged">
<AutoSuggestBox.TextBoxStyle>
<Style TargetType="TextBox">
<Setter Property="IsHandwritingViewEnabled" Value="False"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</AutoSuggestBox.TextBoxStyle>
<AutoSuggestBox.QueryIcon>
<SymbolIcon Symbol="Find" Foreground="Black">
<SymbolIcon.RenderTransform>
<CompositeTransform ScaleX="1" ScaleY="1"/>
</SymbolIcon.RenderTransform>
</SymbolIcon>
</AutoSuggestBox.QueryIcon>
</AutoSuggestBox>
</Grid>
What I want is basically Identical Behaviour as the Groove Music app on Windows, where the Search bar disappears as the Nav View is closed or Minimized. 我想要的基本上是与Windows上的Groove Music应用程序相同的行为,其中当导航视图关闭或最小化时,搜索栏消失。
Instead I get this 相反,我得到这个
I am assuming you meant NavigationView
by NavigationPanel
. 我假设您的意思是
NavigationView
的NavigationPanel
。
This is not how you put an AutoSuggestBox
in NavigationView
. 这不是将
AutoSuggestBox
放在NavigationView
。 NavigationView
has an NavigationView.AutoSuggestBox
property. NavigationView
具有NavigationView.AutoSuggestBox
属性。 You just set an AutoSuggestBox
on this property, and every thing will work as expected. 您只需在此属性上设置一个
AutoSuggestBox
,一切都会按预期进行。 Like this: 像这样:
<NavigationView>
<NavigationView.AutoSuggestBox>
<AutoSuggestBox x:Name="NavViewSearchBox" QueryIcon="Find"/>
</NavigationView.AutoSuggestBox>
</NavigationVew>
You don't have to hide/show this AutoSuggestBox
yourself. 您不必自己隐藏/显示此
AutoSuggestBox
。 NavigationView
will automatically do this for you. NavigationView
将自动为您执行此操作。 Also, you don't have to put thie AutoSuggestBox
inside any grid or anything. 另外,您不必将
AutoSuggestBox
放置在任何网格或任何内部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.