https://i.stack.imgur.com/Yiq0v.gif 左邊有一個帶組的 ListView。右邊有一個沒有 gropus 的 ListView。這是相同的代碼。不同之處在于滿足條件時,就會創建組?,F在,第一件事。看字體顏色。在沒有組的 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 關注
- 83 瀏覽
添加回答
舉報
0/150
提交
取消