我正在UWP应用中实施Flyout,如下图所示。我希望Flyout中的AutoSuggestBox出现在(并填充)PageHeader中,但它出现在它下面。
这是我的XAML:
<Button x:Name="searchButton" Margin="0" Padding="0" BorderThickness="0" RelativePanel.AlignBottomWith="pageHeader">
<Button.Content>
<FontIcon Height="48" Width="48" Glyph=""/>
</Button.Content>
<Button.Flyout>
<Flyout>
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="Height" Value="40"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<StackPanel Margin="0" VerticalAlignment="Top">
<AutoSuggestBox x:Name="innerSearchBox" PlaceholderText="Search" VerticalAlignment="Top"/>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
如何让AutoSugesstBox出现并填充PageHeader?
答案 0 :(得分:2)
将弹出布局设置为左侧。
<Flyout Placement="Left">
如果要使AutoSuggestBox覆盖应用程序的整个宽度,请将AutoSuggestBox的宽度设置为ApplicationView宽度。
您可以通过
执行此操作public MainPage()
{
this.InitializeComponent();
ApplicationView.GetForCurrentView().VisibleBoundsChanged += MainPage_VisibleBoundsChanged;
var bound = ApplicationView.GetForCurrentView().VisibleBounds;
innerSearchBox.Width = (int)bound.Width - 48; //48 is the size of the button
}
private void MainPage_VisibleBoundsChanged(ApplicationView sender, object args)
{
var bound = ApplicationView.GetForCurrentView().VisibleBounds;
innerSearchBox.Width = (int)bound.Width - 48;
}