0
當我嘗試綁定數據視圖到數據網格並試圖讓它顯示第一行作爲一個rowheader時,我有一個問題。WPF datagrid rowheader當綁定到dataview
我的DataGrid是這樣的:
<DataGrid DockPanel.Dock="Top" Margin="15,15" HorizontalAlignment="Left" Name="ReportDataGrid" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" AutoGenerateColumns="True" CanUserResizeRows="False" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" HeadersVisibility="All" Visibility="{Binding Path=ShowReportDataGrid}" SelectionMode="Single" SelectionUnit="Cell" ClipboardCopyMode="IncludeHeader">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Width" Value="48"></Setter>
</Style>
</DataGrid.CellStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="{StaticResource DataGrid_Style_Header}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="10,0,10,0"/>
<Setter Property="Width" Value="48"></Setter>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="DataGridRowHeader">
<Setter Property="Background" Value="{StaticResource DataGrid_Style_Header}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="10,0,10,0"/>
<Setter Property="Width" Value="48"></Setter>
</Style>
</DataGrid.RowHeaderStyle>
</DataGrid>
與此代碼會發生什麼情況是,DataGrid中插入的rowHeader,然後在網格中的其餘部分提出從數據視圖中的數據,的rowHeader空。將數據視圖的第一列添加到rowheader會有什麼好的解決方案?