问题描述
我需要在组合框的所有弹出行下方添加一行。 所以现在我有了ComboBox,看起来像这样:
并弹出使用此XAML代码实现的行:
<Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"
IsOpen="{TemplateBinding IsDropDownopen,Mode=TwoWay}"
MinWidth="{Binding Bounds.Width,RelativeSource={RelativeSource TemplatedParent}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
PlacementTarget="{TemplateBinding}"
IsLightdismissEnabled="True">
<Grid>
<Grid.RowDeFinitions>
<RowDeFinition Height="*"/>
<RowDeFinition Height="5*"/>
<RowDeFinition Height="10*"/>
</Grid.RowDeFinitions>
<Border x:Name="PopupBorder"
Grid.Row="1"
Background="#00A9FF"
BorderBrush="Black"
BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}"
Margin="0,-1,-1"
Padding="0"
HorizontalAlignment="Stretch"
CornerRadius="0"
Grid.Column="2"
>
<ScrollViewer>
<ItemsPresenter Name="PART_ItemsPresenter"
Items="{TemplateBinding Items}"
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
ItemsPanel="{TemplateBinding ItemsPanel}"
ItemTemplate="{TemplateBinding ItemTemplate}"
VirtualizationMode="{TemplateBinding VirtualizationMode}"
/>
</ScrollViewer>
</Border>
</Grid>
</Popup>
我需要使ComboBox与此类似:
我无法插入其他边框以使线条显示出来,所以我不知道该怎么办。
解决方法
您需要修改ComboBoxItem
而不是ComboBox
的样式/控件模板。
您可以修改ComboBoxItem
的控制模板,并将行放在此处。
另一种选择是为ItemTemplate
的样式创建默认的ComboBox
,但是开发人员很容易覆盖它。