Привет, у меня есть ListView с GridView View
<ListView>
<ListView.View>
<GridView.......
И в нем у меня есть несколько GridViewColumn, которые я хочу, чтобы ширина столбцов соответствовала наибольшему элементу ... но это не работает, кажется, что для базы данных он не обновляет размер столбца, а вместо этого использует предыдущий тип данных самый большой товар ..
У меня есть несколько стилей, которые изменяют макет:
<Style TargetType="{x:Type ListView}">
<Setter Property="BorderThickness" Value="1.000001"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="BorderBrush" Value="{x:Null}"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style TargetType="ListViewItem">
<Style.Resources>
<!-- Foreground for Selected ListViewItem -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
Color="Black"/>
<!-- Background for Selected ListViewItem -->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
</Style.Resources>
</Style>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Background" Value="{StaticResource PrimaryBrush}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
<Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="true" Margin="2,0">
<Rectangle x:Name="normal" />
<ContentPresenter x:Name="HeaderContent"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="5"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Кто-нибудь знает, почему wpf ведет себя так? и есть ли решение?