WPF Custom Style article-datagrid

Source: Internet
Author: User

Style:

<!--the DataGrid style--
<style targettype= "DataGrid" >
<setter property= "rowheaderwidth" value= "0" ></Setter>
<setter property= "AutoGenerateColumns" value= "False" ></Setter>
<setter property= "Canuseraddrows" value= "False" ></Setter>
<setter property= "Canuserresizecolumns" value= "False" ></Setter>
<setter property= "Canuserresizerows" value= "False" ></Setter>
<setter property= "Horizontalgridlinesbrush" value= "Lightgray" ></Setter>
<setter property= "Verticalgridlinesbrush" value= "Lightgray" ></Setter>
<setter property= "IsReadOnly" value= "True" ></Setter>
<setter property= "borderthickness" value= "1,0" ></Setter>
<setter property= "BorderBrush" value= "Lightgray" ></Setter>
<setter property= "RowHeight" value= "></Setter>"
<setter property= "verticalscrollbarvisibility" value= "Auto" ></Setter>
</Style> <!--DataGrid header Style--
<style targettype= "Datagridcolumnheader" >
<setter property= "FontSize" value= "></Setter>"
<setter property= "Background" value= "{StaticResource BgColor}" ></Setter>
<setter property= "borderthickness" value= "0,0,1,1" ></Setter>
<setter property= "BorderBrush" value= "Lightgray" ></Setter>
<setter property= "horizontalcontentalignment" value= "Center" ></Setter>
</Style> <!--datagrid check box style-<style targettype= "checkbox" x:key= "Verticalcheckbox" >
<setter property= "VerticalAlignment" value= "Center" ></Setter>
<setter property= "FontSize" value= "></Setter>"
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "{x:type CheckBox}" >
<stackpanel name= "sp" horizontalalignment= "Center" >
<contentpresenter horizontalalignment= "Center" margin= "2" ></ContentPresenter>
<border x:name= "BD" borderthickness= "1.5" height= "width=" "borderbrush=" > "Gray"
<Border.Background>
<lineargradientbrush startpoint= "0,0" endpoint= ">"
<gradientstop color= "Lightgray" offset= "0.05"/>
<gradientstop color= "White" offset= "1"/>
</LinearGradientBrush>
</Border.Background>
<path name= "Checkpath" width= "Up" height= "stroke=" "Black" strokethickness= "2" ></Path>
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<trigger property= "IsChecked" value= "True" >
<setter targetname= "Checkpath" property= "Data" value= "M 1.5,5 L 7,13 17,0" ></Setter> &L T;/trigger>
<trigger property= "IsMouseOver" value= "True" >
<setter targetname= "BD" property= "Background" value= "Lightgray" ></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <!--DataGrid cell selection Style-
<style targettype= "DataGridCell" >
<Style.Triggers>
<trigger property= "IsSelected" value= "True" >
<setter property= "Background" value= "#FFC7CBCA"/>
<setter property= "borderthickness" value= "0" ></Setter>
</Trigger>
</Style.Triggers>
</Style> <!--DataGrid button Style Blue--
<style x:key= "Btninfo" targettype= "button" >
<setter property= "Width" value= "></Setter>"
<setter property= "Foreground" value= "white" ></Setter>
<setter property= "FontSize" value= "></Setter>"
<setter property= "Margin" value= "0,2" ></Setter>
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "button" >
<border name= "BD" cornerradius= "3" borderthickness= "1" borderbrush= "Lightgray" background= "#FF2F6DC1" >
<contentpresenter content= "{TemplateBinding contentcontrol.content}" horizontalalignment= "Center" verticalalignment= "Center"/>
</Border>
<ControlTemplate.Triggers>
<trigger property= "Button.ismouseover" value= "True" >
<setter targetname= "BD" property= "Opacity" value= "0.6" ></Setter>
</Trigger>
<trigger property= "ispressed" value= "True" >
<setter targetname= "BD" property= "Background" value= "#FF9BCEF7" ></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> Transferred from: http://www.cnblogs.com/DemonJ/p/6283477.html

WPF Custom Style article-datagrid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.