我有一个DataGrid,这是很简单的,只要DataGrid中去。出于某种原因或其他,头不与数据的其余部分对准,如图以下屏幕截图:
I've got a DataGrid, which is quite simple as far as DataGrids go. For some reason or other, the headers are not aligned with the rest of the data, as shown in the screenshot below:
我在网上搜索,但似乎无法找到它的解决方案。这是我的DataGrid code:
I've searched the internet but cannot seem to find a solution for it. Here is my DataGrid code:
Grid>
<DataGrid Name="dgAttributes"
ItemsSource="{Binding itemsSource}"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
>
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding Field}" Header="Fields"/>
<DataGridComboBoxColumn Width="95" IsReadOnly="False" Header="Order" ItemsSource="{Binding Source={StaticResource SortOrderProvider}}" SelectedItemBinding="{Binding SortBy, Mode=TwoWay}"/>
<DataGridCheckBoxColumn Width="Auto" IsReadOnly="False" Binding="{Binding GroupBy}" Header="Group By"/>
<DataGridComboBoxColumn Width="85" IsReadOnly="False" Header="Aggregate" ItemsSource="{Binding Source={StaticResource AggregateProvider}}" SelectedItemBinding="{Binding AggregateBy, Mode=TwoWay}"/>
<DataGridTextColumn Width="Auto" IsReadOnly="False" Binding="{Binding Having}" Header="Having"/>
<DataGridTextColumn Width="Auto" IsReadOnly="False" Binding="{Binding DisplayOrder}" Header="Display Order"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
这也可能是值得一提的是,当我点击了组合框的细胞之一,头赞同正常。
It may also be worth mentioning that when I click on one of the Combobox cells, the headers align themselves properly.
您肯定是有一些风格或东西是隐藏在左上 选
数据网格的按钮。因此,列被移动到左一点
You are definitely having some style or something that is hiding the top left Select All
button of datagrid. Hence the columns are shifted to left a little.
使用这个线程弄个该按钮在 DataGrid.OnLoad
并检查其能见度
属性。
Use this thread to get hold of that button in DataGrid.OnLoad
and check its Visibility
property.
全选按钮WPF的DataGrid
如果其collpased /隐藏,设置能见度 Visbility.Visible
。或者,检查其宽度
为零,并设置相应的宽度
。
If its collpased/hidden, set the visibility to Visbility.Visible
. Or check its Width
being zero and set appropriate Width
.
上一篇:的onPause()的AndroidonPause、Andr、oid
下一篇:LegacyUnhandledExceptionPolicy不允许捕捉(吞)ThreadAbortException?不允许、LegacyUnhandledExceptionPolicy、Thread