0

这是来自MSDN的示例。

<GroupStyle>
  <GroupStyle.ContainerStyle>
    <Style TargetType="{x:Type GroupItem}">
      <Setter Property="Margin" Value="0,0,0,5"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type GroupItem}">
            <Expander IsExpanded="True" BorderBrush="#FFA4B97F" 
                      BorderThickness="0,0,0,1">
              <Expander.Header>
                <DockPanel>
                  <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" 
                             Margin="5,0,0,0" Width="100"/>
                  <TextBlock FontWeight="Bold" 
                             Text="{Binding Path=ItemCount}"/>
                </DockPanel>
              </Expander.Header>
              <Expander.Content>
                <ItemsPresenter />
              </Expander.Content>
            </Expander>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </GroupStyle.ContainerStyle>
</GroupStyle>

如何让它占据列表框的整个宽度?(Horizo​​ntalScrollBar 被禁用)?我真正需要的是 DockPanel 被拉伸。

4

1 回答 1

1

您必须在项目中包含 PresentationFramework.Aero 的引用。在您的 ListBox 之后,您必须插入此属性:

<ListBox 
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    HorizontalContentAlignment="Stretch"
>
</ListBox>
于 2012-04-05T14:35:33.700 回答