blend2008. 12. 26. 17:04

일단 WPF ToolKit에서 제공하는 DataGrid를 수정하기 위해서는 2가지를 수정해야한다

기본적인것은 아주쉽다 그냥 Style하나 입혀놓고 Datagrid에서 지원해주는 properties를 하나의 스타일로 입히는것이다.

그냥 app.xaml에서

     <Style x:Key="dataGridBlack" TargetType="{x:Type Custom:DataGrid}">
                <Setter Property="RowBackground" Value="#171717" />
                <Setter Property="Foreground" Value="#FF999999" />
                <Setter Property="HorizontalGridLinesBrush" Value="#FF2F2F2F" />
                <Setter Property="VerticalGridLinesBrush" Value="#FF2F2F2F" />
                <Setter Property="RowHeight" Value="34" />
                <Setter Property="ColumnHeaderHeight" Value="34"/>
                <Setter Property="RowHeaderWidth" Value="0"/>
                <Setter Property="BorderBrush" Value="#FF2F2F2F"/>
                <Setter Property="MaxHeight" Value="500"/>
                <Setter Property="Background" Value="#FF171717"/>
            </Style>

이런식으로 dataGridBlack을 하나 만들어서 스타일을 적용하면 된다......

자이제 헤더를 입혀보자 헤더입히는법은 blend로는 이미 사용법을 썻었고

<Style x:Key="HeaderStyle" TargetType="{x:Type Custom:DataGridColumnHeader}">
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="Background" Value="#FF202020"/>
                <Setter Property="BorderBrush" Value="#2f2f2f" />
                <Setter Property="BorderThickness" Value="1 1 1 1" />
                <Setter Property="Foreground" Value="#666666"/>
                <Setter Property="Margin" Value="0,0,0,0"/>               
            </Style>

헤더 스타일을 정의를 이렇게 해놓으면 blend에 보여서 수정하면 된다

이제 제일 힘든 스크롤바

일단 template 을 정의 해야한다.


이렇게 dataGridBlack 이라는 스타일(datagrid의 색상이나 머 안의 선색상등 배경) DataGridControlTemplateBlack
이라는 template 2개가 check 되어있다... template가 머냐하면 어떤 control을 edit즉 속으로 들어가서 수정한 값의 스타일정의다

header값이랑 scrollbar 도 다 datagrid template 에서 수정한것이 때문에 template style을 정의해줘야 바뀐다.


일단 edit tempate을 해서 control 속을 보자


Part_verticalScroolBar가 세로 scrollbar이고 HorizontalScrollbar가 가로 scrollbar이다..

이제 edit해서 마음껏수정하면 된다........




Posted by 동동(이재동)