2014-11-14 3 views
1

WPF 'DataGrid'에서는 가로 격자 선의 색을 HorizontalGridLinesBrush 속성으로 수정할 수 있습니다.선택한 행에 대해서만 HorizontalGridLinesBrush 변경

일부 항목은 부울 속성이 true로 설정되어 있으므로 수평 격자 선 브러시를 다른 색상으로 설정하면 강조 표시가으로 되길 원합니다.

가로형 그리드 선의 색상을 세로줄 만 변경할 수 있습니까?

답변

2

DataGrid.HorizontalGridLinesBrushDataGrid 당 설정 그래서 당신은 행마다 변경할 수 없습니다하지만 당신은 사용자 정의 내 문제를 해결

<DataGrid ... GridLinesVisibility="Vertical"> 
    <DataGrid.RowStyle> 
     <Style TargetType="{x:Type DataGridRow}"> 
      <Setter Property="BorderThickness" Value="0,0,0,1"/> 
      <Setter Property="BorderBrush" Value="Black"/> 
      <Style.Triggers> 

       <!-- this will trigger when row is selected --> 
       <Trigger Property="IsSelected" Value="True">       
        <Setter Property="BorderBrush" Value="Red"/> 
       </Trigger> 

       <!-- this will trigger when Highlight property of the view model is true --> 
       <DataTrigger Binding="{Binding Highlight}" Value="True"> 
        <Setter Property="BorderBrush" Value="Green"/> 
       </DataTrigger> 
      </Style.Triggers> 
     </Style> 
    </DataGrid.RowStyle> 
</DataGrid> 
+1

감사합니다 DataGridRow 스타일을, 수평 격자 선을 비활성화하고 만들어 기본 수평 라인 동작을 대체 할 수 있습니다! :) –