如何在UWP组合框中的下拉菜单中添加页脚

时间:2019-05-22 12:34:47

标签: c# drop-down-menu uwp combobox uwp-xaml

我正在开发UWP应用程序。我希望在显示组合框项目的地方显示页脚。如何在UWP中实现它。帮我实现这个。

Want to achieve like this snapshot

注意: 这里正在使用Microsoft Combobox

1 个答案:

答案 0 :(得分:0)

您只需要自定义ComboBox默认样式,并将TextBlock控件放在下拉菜单中。

请参见Use tools to work with styles easily以编辑副本ComboBox样式并找到Popup控件。将TextBlock如下所示:

<Style x:Key="ComboBoxStyle1" TargetType="ComboBox">
......

<Popup x:Name="Popup">                      
<ScrollViewer>
      <RelativePanel>
            <Border  x:Name="PopupBorder" BackgroundSizing="OuterBorderEdge" Background="{ThemeResource ComboBoxDropDownBackground}" BorderThickness="0 0 0 2" BorderBrush="{ThemeResource ComboBoxDropDownBorderBrush}" HorizontalAlignment="Stretch" Margin="0,-1,0,-1" Padding="{ThemeResource ComboBoxDropdownBorderPadding}">
                   <ScrollViewer x:Name="ScrollViewer" AutomationProperties.AccessibilityView="Raw" BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}" Foreground="{ThemeResource ComboBoxDropDownForeground}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" MinWidth="{Binding TemplateSettings.DropDownContentMinWidth, RelativeSource={RelativeSource Mode=TemplatedParent}}" VerticalSnapPointsType="OptionalSingle" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalSnapPointsAlignment="Near" ZoomMode="Disabled">
                        <ItemsPresenter Margin="{ThemeResource ComboBoxDropdownContentMargin}" />
                   </ScrollViewer>
            </Border>
            <TextBlock Text="Manage Styles" RelativePanel.Below="PopupBorder"></TextBlock>
      </RelativePanel>
</ScrollViewer>
</Popup>