我想让WPF数据网格看起来类似于下图中的HTML网格:
http://img443.imageshack.us/img443/2563/saltoftheearth.jpg
有谁知道一个简单的方法吗?
此致 S.
答案 0 :(得分:2)
我设法使用资源文件中的以下代码使其看起来像这样(http://img697.imageshack.us/img697/9417/failedwpfdatagridstylin.jpg)。但是,它仍然看起来不像HTML对应物(http://img443.imageshack.us/img443/2563/saltoftheearth.jpg)....它有许多边界....关于如何使这个WPF数据网格看起来更好的任何想法?
值=“12”/>
<Style x:Key="DataGridCellStyle" TargetType="{x:Type my:DataGridCell}" >
<Setter Property="FontFamily"
Value="Tahoma" />
<Setter Property="FontSize"
Value="12" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="BorderBrush" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="DataGridStyle"
TargetType="{x:Type my:DataGrid}" >
<Setter Property="RowHeaderWidth"
Value="0" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="SelectionUnit"
Value="Cell" />
<Setter Property="SelectionMode"
Value="Single" />
<Setter Property="AutoGenerateColumns"
Value="false" />
<Setter Property="CanUserAddRows"
Value="False" />
<Setter Property="CanUserDeleteRows"
Value="False" />
<Setter Property="CanUserResizeRows"
Value="False" />
<Setter Property="CanUserResizeColumns"
Value="False" />
<Setter Property="CanUserSortColumns"
Value="True" />
<Setter Property="CanUserReorderColumns"
Value="False" />
<Setter Property="IsReadOnly"
Value="True" />
</Style>
答案 1 :(得分:0)