昨天,客户提个新需求,要求dataGrid 水平滚动时,第一列固定显示,不能进行隐藏。
我使用的是Xceed 控件,对此控件不是很熟悉,在网上查询了下, 用此段代码可以实现。
<code>
<xcdg:DataGridControl>
<xcdg:DataGridControl.View>
<xcdg:TableView FixedColumnCount="2" />
</xcdg:DataGridControl.View>
<xcdg:DataGridControl.DetailConfigurations>
<xcdg:DetailConfiguration RelationName="MyDetail" xcdg:TableView.FixedColumnCount="5" />
</xcdg:DataGridControl.DetailConfigurations>
</xcdg:DataGridControl>
</code>
功能实现了 ,可是 样式全变化了,估计用户接受不了。所以我就换成了VS1012自带的控件,DataGrid.
FrozenColumnCount="1" 实现了,然后又重新写了下样式。
<DataGrid.RowStyle >
<Style TargetType="DataGridRow">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FFF1FAFF"/>
<Setter Property="FontSize" Value=" 16"/>
<Setter Property="Height" Value="26"/>
<Setter Property="Foreground" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle >
<Style TargetType="DataGridCell">
<Style.Triggers >
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Gray"/>
<Setter Property="FontSize" Value=" 16"/>
<Setter Property="Height" Value="26"/>
<Setter Property="Foreground" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>