1
我有WPF數據網格的網格列在這裏添加的是XAMLWPF DataGrid列寬度調整時最大限度地
<DataGrid x:Name="grdProgramList" IsReadOnly="True"
Grid.Column="1" Grid.Row="1"
Width="{Binding Path=ActualWidth, ElementName=grid}"
RenderOptions.ClearTypeHint="Enabled"
TextOptions.TextFormattingMode="Display"
HeadersVisibility="All"
Margin="5"
SelectionMode="Single"
SelectionUnit="FullRow"
SelectionChanged="AzureDataGrid_Selected"
ItemsSource="{Binding Path=Uninstaller.ProgramCollection}"
SelectedItem="{Binding Uninstaller.SelectedProgramDetails, Mode=TwoWay}"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="PROGRAM NAME"
Binding="{Binding ProgramDetails.ProgramName}"
MinWidth="325" />
<DataGridTextColumn Header="Publisher"
Binding="{Binding ProgramDetails.PublisherName}" />
<DataGridTextColumn Header="Estimated Size (KB)"
Binding="{Binding ProgramDetails.EstimatedSize}" />
<DataGridTextColumn Header="Version"
Binding="{Binding ProgramDetails.Version}" />
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/>
<Style.Triggers>
<!-- IsSelected -->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#CC119EDA" />
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" Value="#CC119EDA" />
</MultiDataTrigger>
<!-- IsHover -->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#66119EDA" />
<Setter Property="BorderBrush" Value="#66119EDA" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
</DataGrid>
當它重新大小我想,以適應所有列的寬度網格寬度
現在看起來像這樣。