https://i.stack.imgur.com/Yiq0v.gif 左边有一个带组的 ListView。右边有一个没有 gropus 的 ListView。这是相同的代码。不同之处在于满足条件时,就会创建组。现在,第一件事。看字体颜色。在没有组的 ListView 中,有默认的蓝色。在带组的 ListView 中,字体是黑色的。第二件事。查看列大小调整。在没有组的 ListView 中,一切都按预期工作。但是在带有组的 ListView 中,发生了一些奇怪的事情......当我增加名称列时,限制列值在某个阶段消失。整个内容都在移动。我试图将 ListView 更改为 DataGrid,但结果更糟。那么,这里可能是什么问题?这是我的小组的风格:<Style TargetType="{x:Type GroupItem}" x:Key="CategoryStyle"> <Style.Triggers> <DataTrigger Binding="{Binding Name.IsDefault}" Value="False"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Expander IsExpanded="True" Width="200"> <Expander.Header> <DockPanel Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Expander}}, Path=ActualWidth}"> <Button DockPanel.Dock="Right" Style="{StaticResource RoundBtnStyle}" Content="+" Margin="0,0,28,0" Width="20" Height="20" Tag="{Binding}" Command="{Binding DataContext.AddItemToCategoryCommand, RelativeSource={RelativeSource AncestorType={x:Type app:DocumentControl}}}" </DockPanel> </Expander.Header> <ItemsPresenter /> </Expander> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style>
1 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
您的字体颜色未设置为您为其发布 XAML 的任何一种样式,这意味着它正在被父对象继承,或者未在您的问题中发布的样式。
您的调整大小问题GroupItem是由控件模板中的以下行引起的:
<Expander IsExpanded="True" Width="200">
您已经为扩展器元素硬编码了“200”的宽度,这导致它在其他网格列的尺寸小于 200 时覆盖它们,这让事情看起来有点奇怪。
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报
0/150
提交
取消
