2010-05-20 148 views

回答

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> 
0

你可以在這裏看看,在C# Corner,有很多有用的教程那裏,Im相當肯定你能找到它,像this one