First!
I know it can seem a kind of dup nevertheless it isn't.
I have a grid as a data template for DataGrid.RowDetails
.
It has three columns: two with Width="Auto"
and the 3d with Width="*"
<DataTemplate x:Key="NotEmptyDistributionsTemplateKey">
<DataGrid ItemsSource="{Binding SoftwareVersionDistributions}"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="True"
CanUserSortColumns="False"
IsReadOnly="True"
CanUserResizeRows="False"
AutoGenerateColumns="False"
RowHeaderWidth="0"
Margin="20,5"
HorizontalAlignment="Stretch">
<DataGrid.Columns>
<DataGridTextColumn
Header="Architecture"
Binding="{Binding SoftwareArchitecture.Name, TargetNullValue=Все, FallbackValue=Все}"
Width="Auto"/>
<DataGridTextColumn
Header="Language"
Binding="{Binding SysCodepage.Title, TargetNullValue=Все, FallbackValue=Все}"
Width="Auto"/>
<DataGridHyperlinkColumn
Header="Link"
Binding="{Binding DownloadLink}"
Width="*"
CanUserResize="False"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
This template shows exactly 3 columns, if Grid is nested in a cell.
But when it is used as RowDetaislTemplate
4th empty column appears.
This makes me mad.
Does anybody have ideas why this can happen?
Update 1. How it looks:
Update 2.
Finally I found the soultion. Just added ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Now it's ok:
But I cannot understand this odd behavior.
Update 3 (may be helpful to someone)
Recently we've found a bug which our users had and the developers did not. The bug was again about DataGrid's width and alignment. Well, may be this was not really a bug, but we had different behavior of the control.
The research revealed that when installing .net framework 4.5 installer also updated .net framework 4.0. This update changed somehow DataGrid's behavior. (to the expected one)
We asked our users to install framework 4.5 and the problem dissapeared. Though our app still targets .net 4.0
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…