0

我需要在 Combobox 中每个弹出的行下方添加一行。所以现在我的 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,0,-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>

我需要使组合框类似于这个: 所需的组合框

我无法插入一些额外的边框来使线条出现,所以我不知道该怎么做。

4

1 回答 1

1

您需要修改样式/控件模板,ComboBoxItem而不是ComboBox.

您可以修改控件模板ComboBoxItem并将该行放在那里。

ItemTemplate另一种选择是为's 样式创建一个默认值ComboBox,但这很容易被开发人员覆盖。

于 2020-09-17T15:20:24.393 回答