WPF常用样式总结
程序员文章站
2024-01-16 15:49:35
常用控件样式: ......
常用控件样式:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- 文字按钮 --> <style x:key="stltxtbtn" targettype="{x:type button}"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type button}"> <border background="transparent"> <border x:name="bd" background="#1aa4f5" cornerradius="2" padding="{templatebinding padding}"> <textblock x:name="txt" verticalalignment="center" horizontalalignment="center" margin="5 2 5 2" foreground="white" ><inlineuicontainer> <contentpresenter /> </inlineuicontainer></textblock> </border> </border> <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="bd" property="background" value="#33c4f5"/> </trigger> <trigger property="ispressed" value="true"> <setter targetname="txt" property="fontsize" value="11"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!-- 文字按钮浅色 --> <style x:key="stltxtbtnlight" targettype="{x:type button}"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type button}"> <border background="transparent"> <border x:name="bd" background="#0cc663" cornerradius="2" padding="{templatebinding padding}"> <textblock x:name="txt" verticalalignment="center" horizontalalignment="center" margin="5 2 5 2" foreground="white" ><inlineuicontainer> <contentpresenter /> </inlineuicontainer></textblock> </border> </border> <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="bd" property="background" value="#0cb653"/> </trigger> <trigger property="ispressed" value="true"> <setter targetname="txt" property="fontsize" value="11"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!-- 图片按钮 --> <controltemplate x:key="tmplimgbtn" targettype="{x:type button}"> <border x:name="bd" width="{templatebinding width}" height="{templatebinding height}" cornerradius="2" background="{templatebinding background}" > <stackpanel orientation="horizontal" horizontalalignment="center"> <image x:name="img" margin="-2 2 3 0" width="15" height="15" verticalalignment="center" stretch="uniformtofill" source="{templatebinding tag}" /> <textblock x:name="txt" fontsize="{templatebinding property=fontsize}" foreground="{templatebinding foreground}" text="{templatebinding property=content}" verticalalignment="center"/> </stackpanel> </border> <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="bd" property="background" value="#33c4f5"/> </trigger> <trigger property="ispressed" value="true"> <setter targetname="txt" property="fontsize" value="11"/> <setter targetname="img" property="width" value="14"/> <setter targetname="img" property="height" value="14"/> </trigger> </controltemplate.triggers> </controltemplate> <!-- 图片按钮 --> <style x:key="stlimgbtn" targettype="{x:type button}"> <setter property="margin" value="5,0"/> <setter property="height" value="25"/> <setter property="foreground" value="white"/> <setter property="background" value="#15a6f9"/> <setter property="template" value="{staticresource tmplimgbtn}"/> </style> <!-- 只有图片的按钮 --> <controltemplate x:key="tmplbtnimgonly" targettype="{x:type button}"> <border background="#aa013440" width="{templatebinding width}" height="{templatebinding height}" > <image x:name="img" width="16" height="16" stretch="fill" source="{templatebinding property=content}"></image> </border> <controltemplate.triggers> <trigger property="ispressed" value="true"> <setter targetname="img" property="margin" value="2"></setter> </trigger> <trigger property="isenabled" value="false"> <setter targetname="img" property="opacity" value="0.5"></setter> </trigger> </controltemplate.triggers> </controltemplate> <!-- 输入框样式 --> <style targettype="{x:type textbox}" x:key="stltxt"> <setter property="horizontalalignment" value="left"/> <setter property="height" value="28"/> <setter property="margin" value="5,0,0,0"/> <setter property="foreground" value="white"/> <setter property="caretbrush" value="white"/> <setter property="template"> <setter.value> <controltemplate targettype="{x:type textbox}"> <border cornerradius="2" borderthickness="0" borderbrush="#eee" background="#0a5d7b"> <grid> <border x:name="borderbase" background="transparent" borderthickness="1.4,1.4,1,1" borderbrush="transparent" /> <label x:name="textprompt" content="{templatebinding tag}" foreground="gray" verticalalignment="center" visibility="collapsed" focusable="false" /> <scrollviewer margin="2 0 0 0" verticalalignment="center" x:name="part_contenthost" /> </grid> </border> <controltemplate.triggers> <multitrigger> <multitrigger.conditions> <condition property="isfocused" value="false"/> <condition property="text" value=""/> </multitrigger.conditions> <setter property="visibility" targetname="textprompt" value="visible"/> </multitrigger> <trigger property="isfocused" value="true"> <setter property="borderthickness" targetname="borderbase" value="2.4,1.4,1,1"/> </trigger> <trigger property="isenabled" value="false"> <setter property="foreground" value="gray" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!-- 输入框样式 --> <style targettype="{x:type richtextbox}" x:key="stlrtb"> <setter property="verticalscrollbarvisibility" value="auto"/> <setter property="horizontalalignment" value="left"/> <setter property="margin" value="5 0 0 0"/> <setter property="foreground" value="white"/> <setter property="caretbrush" value="white"/> <setter property="template"> <setter.value> <controltemplate targettype="{x:type richtextbox}"> <border borderthickness="0" borderbrush="#eee" cornerradius="2" background="#0a5d7b"> <grid> <border x:name="borderbase" background="transparent" borderthickness="1.4,1.4,1,1" borderbrush="transparent" /> <label x:name="textprompt" content="{templatebinding tag}" foreground="gray" verticalalignment="top" visibility="collapsed" focusable="false" /> <border x:name="border" margin="0 8 0 5"> <scrollviewer margin="0" verticalalignment="top" x:name="part_contenthost" height="{binding actualheight, elementname=border}" /> </border> </grid> </border> <controltemplate.triggers> <multitrigger> <multitrigger.conditions> <condition property="isfocused" value="false"/> </multitrigger.conditions> <setter property="visibility" targetname="textprompt" value="visible"/> </multitrigger> <trigger property="isfocused" value="true"> <setter property="borderthickness" targetname="borderbase" value="2.4,1.4,1,1"/> </trigger> <trigger property="isenabled" value="false"> <setter property="foreground" value="gray" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!--下拉条目样式--> <style targettype="{x:type comboboxitem}" x:key="stlcbxitem"> <setter property="horizontalcontentalignment" value="stretch" /> <setter property="verticalcontentalignment" value="center" /> <setter property="renderoptions.cleartypehint" value="enabled" /> <setter property="borderthickness" value="0" /> <setter property="height" value="28" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type comboboxitem}"> <grid background="{templatebinding background}" margin="0,0.5"> <border x:name="itembackground" cornerradius="1" ishittestvisible="false" snapstodevicepixels="{templatebinding snapstodevicepixels}" borderthickness="{templatebinding borderthickness}" borderbrush="{templatebinding borderbrush}" background="{templatebinding background}" /> <contentpresenter x:name="contentpresenter" margin="{templatebinding padding}" verticalalignment="{templatebinding verticalcontentalignment}" horizontalalignment="{templatebinding horizontalcontentalignment}" /> </grid> <controltemplate.triggers> <trigger property="isselected" value="true"> <setter targetname="itembackground" property="background" value="#224466" /> </trigger> <trigger property="ismouseover" value="true"> <setter targetname="itembackground" property="background" value="#226688" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!-- 下拉框样式 --> <style targettype="{x:type togglebutton}" x:key="stltogglebutton"> <setter property="foreground" value="white"/> <setter property="template"> <setter.value> <controltemplate> <grid background="transparent"> <grid.columndefinitions> <columndefinition width="0.7*"/> <columndefinition width="0.3*" maxwidth="30" minwidth="16"/> </grid.columndefinitions> <textblock grid.column="0" foreground="white" margin="5 0 0 0" text="{binding text, relativesource={relativesource ancestortype={x:type combobox}, mode=findancestor}}" verticalalignment="center"/> <border grid.column="1" x:name="back" background="transparent" borderthickness="0" borderbrush="transparent"> <path x:name="pathfill" fill="#1b94e0" width="8" height="6" strokethickness="0" data="m5,0 l10,10 l0,10 z" rendertransformorigin="0.5,0.5" stretch="fill"> <path.rendertransform> <transformgroup> <scaletransform /> <skewtransform /> <rotatetransform angle="180"/> <translatetransform/> </transformgroup> </path.rendertransform> </path> </border> </grid> <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="pathfill" property="fill" value="#1b94e0"/> <setter targetname="back" property="background" value="transparent"/> <setter targetname="back" property="borderbrush" value="transparent"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!-- 下拉框样式 --> <style x:key="stlcbx" targettype="{x:type combobox}" > <setter property="snapstodevicepixels" value="true"/> <setter property="scrollviewer.horizontalscrollbarvisibility" value="auto"/> <setter property="scrollviewer.verticalscrollbarvisibility" value="auto"/> <setter property="scrollviewer.cancontentscroll" value="true"/> <setter property="horizontalalignment" value="left"/> <setter property="foreground" value="black"/> <setter property="height" value="28"/> <setter property="margin" value="0,0,0,0"/> <setter property="itemcontainerstyle" value="{staticresource stlcbxitem}" /> <setter property="itemtemplate"> <setter.value> <datatemplate> <textblock text="{binding text}" foreground="#fff" margin="0 3 0 3" /> </datatemplate> </setter.value> </setter> <setter property="template"> <setter.value> <controltemplate targettype="{x:type combobox}"> <border borderthickness="0" borderbrush="#eee" cornerradius="2" background="#0a5d7b"> <grid> <togglebutton style="{staticresource stltogglebutton}" ischecked="{binding isdropdownopen, mode=twoway, relativesource={relativesource templatedparent}}" clickmode="press"/> <popup isopen="{templatebinding isdropdownopen}" placement="bottom" x:name="popup" focusable="false" allowstransparency="true" popupanimation="slide" > <border maxheight="{templatebinding maxdropdownheight}" minwidth="{templatebinding actualwidth}" x:name="dropdown" snapstodevicepixels="true" background="transparent" > <border background="#002244" cornerradius="2" margin="0 2 0 0"> <scrollviewer margin="4,6,4,6" style="{dynamicresource scrollviewerstyle}" maxheight="{templatebinding maxdropdownheight}" snapstodevicepixels="true" horizontalscrollbarvisibility="auto" verticalscrollbarvisibility="auto" cancontentscroll="true"> <!-- stackpanel 用于显示子级,方法是将 isitemshost 设置为 true --> <stackpanel isitemshost="true" keyboardnavigation.directionalnavigation="contained" background="#002244" /> </scrollviewer> </border> </border> </popup> </grid> </border> </controltemplate> </setter.value> </setter> </style> <!-- 复选框样式 --> <controltemplate x:key="tmplckb" targettype="{x:type checkbox}"> <grid x:name="buttoncontent" width="14" height="14" horizontalalignment="center" verticalalignment="center"> <image x:name="btnimagesrc" stretch="fill" source="/suncreate.common.controls;component/images/controls/复选1.png"/> </grid> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter targetname="btnimagesrc" property="source" value="/suncreate.common.controls;component/images/controls/复选2.png"/> </trigger> </controltemplate.triggers> </controltemplate> <!-- 单选按钮样式(带背景色) --> <controltemplate x:key="tmplrdbbackground" targettype="{x:type radiobutton}"> <grid> <border x:name="bd2" cornerradius="2" opacity="1" borderthickness="1" borderbrush="{templatebinding background}" snapstodevicepixels="true"/> <border x:name="bd" cornerradius="2" opacity="0" background="{templatebinding background}" snapstodevicepixels="true"/> <border x:name="backgroundradioboard" height="{templatebinding property=height}" width="{templatebinding property=width}" background="transparent"> <textblock fontsize="{templatebinding property=fontsize}" text="{templatebinding property=content}" horizontalalignment="center" verticalalignment="center" foreground="{templatebinding property=foreground}"/> </border> </grid> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter targetname="bd" property="opacity" value="1"/> </trigger> <trigger property="ismouseover" value="true"> <setter targetname="bd" property="opacity" value="1"/> </trigger> </controltemplate.triggers> </controltemplate> <!-- 单选按钮样式(带小圆圈) --> <controltemplate x:key="tmplrdbcircle" targettype="{x:type radiobutton}"> <border x:name="radiobtnboard" cornerradius="2" height="{templatebinding property=height}" width="{templatebinding property=width}" background="transparent"> <stackpanel orientation="horizontal"> <image x:name="img" margin="5 0 5 0" width="14" height="14" stretch="fill" source="/suncreate.common.controls;component/images/controls/单选1.png"/> <textblock x:name="txt" margin="0 0 5 0" fontsize="{templatebinding property=fontsize}" text="{templatebinding property=content}" verticalalignment="center" foreground="{templatebinding property=foreground}" /> </stackpanel> </border> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter targetname="img" property="source" value="/suncreate.common.controls;component/images/controls/单选2.png"/> </trigger> <trigger property="ismouseover" value="true"> <setter targetname="radiobtnboard" property="background" value="#331aa4f5"/> </trigger> </controltemplate.triggers> </controltemplate> <!-- 单选按钮样式 --> <controltemplate x:key="tmplrdb" targettype="{x:type radiobutton}"> <border x:name="radiobtnboard" cornerradius="2" height="{templatebinding property=height}" width="{templatebinding property=width}" background="transparent"> <textblock x:name="txt" fontsize="{templatebinding property=fontsize}" text="{templatebinding property=content}" horizontalalignment="center" verticalalignment="center" foreground="{templatebinding property=foreground}"/> </border> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter targetname="radiobtnboard" property="background" value="#1aa4f5"/> </trigger> <trigger property="ismouseover" value="true"> <setter targetname="radiobtnboard" property="background" value="#331aa4f5"/> </trigger> </controltemplate.triggers> </controltemplate> <!-- 单选按钮样式 --> <style x:key="stlrdb" targettype="{x:type radiobutton}"> <setter property="fontsize" value="11"/> <setter property="height" value="22"/> <setter property="width" value="50"/> <setter property="foreground" value="white"/> <setter property="margin" value="5,0"/> <setter property="template" value="{staticresource tmplrdb}"/> </style> <!-- 单选按钮样式(带小圆圈) --> <style x:key="stlrdbcircle" targettype="{x:type radiobutton}"> <setter property="fontsize" value="11"/> <setter property="height" value="22"/> <setter property="foreground" value="white"/> <setter property="margin" value="5,0"/> <setter property="template" value="{staticresource tmplrdbcircle}"/> </style> <!-- 单选按钮样式(带背景色) --> <style x:key="stlrdbbackground" targettype="{x:type radiobutton}"> <setter property="fontsize" value="11"/> <setter property="height" value="22"/> <setter property="width" value="50"/> <setter property="foreground" value="white"/> <setter property="margin" value="5,0"/> <setter property="template" value="{staticresource tmplrdbbackground}"/> </style> <!--slider样式--> <style x:key="stlrepeatbuttonleft" targettype="repeatbutton"> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="repeatbutton"> <border background="#01ffff" snapstodevicepixels="true" /> </controltemplate> </setter.value> </setter> </style> <style x:key="stlrepeatbuttonright" targettype="repeatbutton"> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="repeatbutton"> <border background="#0998b8" snapstodevicepixels="true" /> </controltemplate> </setter.value> </setter> </style> <style x:key="stlthumb" targettype="thumb"> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="thumb"> <grid> <border margin="0 -4 0 -4" background="#01ffff" width="8" height="12" snapstodevicepixels="true"> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="stlthumbreadonly" targettype="thumb"> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="thumb"> <grid> <border margin="0 0 0 0" background="#01ffff" width="0" height="4"> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="stlslider" targettype="slider"> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="slider"> <grid> <border height="4"> <track name="part_track"> <track.decreaserepeatbutton> <repeatbutton style="{staticresource stlrepeatbuttonleft}" command="slider.decreaselarge"/> </track.decreaserepeatbutton> <track.increaserepeatbutton> <repeatbutton style="{staticresource stlrepeatbuttonright}" command="slider.increaselarge"/> </track.increaserepeatbutton> <track.thumb> <thumb style="{staticresource stlthumb}"/> </track.thumb> </track> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="stlsliderreadonly" targettype="slider"> <setter property="isenabled" value="false" /> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="slider"> <grid> <border height="4"> <track name="part_track"> <track.decreaserepeatbutton> <repeatbutton style="{staticresource stlrepeatbuttonleft}" command="slider.decreaselarge"/> </track.decreaserepeatbutton> <track.increaserepeatbutton> <repeatbutton style="{staticresource stlrepeatbuttonright}" command="slider.increaselarge"/> </track.increaserepeatbutton> <track.thumb> <thumb style="{staticresource stlthumbreadonly}"/> </track.thumb> </track> </border> </grid> </controltemplate> </setter.value> </setter> </style> <!--tooltip样式--> <style x:key="stltooltip" targettype="tooltip"> <setter property ="background" value="#99001133"></setter> <setter property ="borderthickness" value="0"></setter> <setter property ="contenttemplate"> <setter.value> <datatemplate> <textblock text="{templatebinding content}" foreground="#fff" background="transparent" textwrapping="wrap"></textblock> </datatemplate> </setter.value> </setter> </style> </resourcedictionary>
单选按钮样式(模拟tab页):
<!-- 单选按钮样式 --> <controltemplate x:key="tmplradiobutton" targettype="{x:type radiobutton}"> <grid> <border x:name="bd" background="transparent" borderthickness="0 0 0 3" borderbrush="transparent" snapstodevicepixels="true"> <textblock x:name="txt" margin="5 0 5 0" text="{templatebinding content}" foreground="#babec2" verticalalignment="center" horizontalalignment="center"></textblock> </border> </grid> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter targetname="bd" property="borderbrush" value="#01f9fe"/> <setter targetname="txt" property="foreground" value="#38faf4"/> </trigger> <trigger property="ismouseover" value="true"> <setter targetname="txt" property="foreground" value="#38faf4"/> </trigger> </controltemplate.triggers> </controltemplate>
单选按钮样式(模拟tab页)效果图:
列表样式(listview样式、datagrid样式):
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!--listview样式(1):无边框,奇偶行颜色不相同--> <style x:key="itemcontainerstyle1" targettype="{x:type listviewitem}" > <setter property="background" value="transparent"/> <setter property="foreground" value="white"></setter> <setter property="fontsize" value="12" /> <setter property="height" value="40"/> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <border x:name="tborder" background="{templatebinding background}"> <gridviewrowpresenter content="{templatebinding content}" columns="{templatebinding gridview.columncollection}"/> </border> <controltemplate.triggers> <trigger property="listview.alternationindex" value="0"> <setter property="background" value="{staticresource itemsalternationindexbackground0}"/> </trigger> <trigger property="listview.alternationindex" value="1"> <setter property="background" value="{staticresource itemsalternationindexbackground1}"/> </trigger> <trigger property="isselected" value="true"> <setter property="foreground" value="{staticresource itemselectedforeground}"/> <setter targetname="tborder" property="background" value="{staticresource itemselectedbackground}" /> </trigger> <trigger property="ismouseover" value="true"> <setter property="foreground" value="{staticresource itemmouseoverforeground}"/> <setter targetname="tborder" property="background" value="{staticresource itemmouseoverbackground}" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!--无边框 带下划线--> <style x:key="bottomlinerowstyle" targettype="{x:type listviewitem}" > <setter property="background" value="transparent"/> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <border borderthickness="0,0,0,1" borderbrush="{staticresource bordercontent}"> <gridviewrowpresenter content="{templatebinding content}" columns="{templatebinding gridview.columncollection}"/> </border> </controltemplate> </setter.value> </setter> <setter property="foreground" value="white"></setter> <setter property="fontsize" value="12" /> <setter property="height" value="40"/> <style.triggers> <trigger property="isselected" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> <trigger property="ismouseover" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> </style.triggers> </style> <style x:key="columnheadercontainerstyle1" targettype="{x:type gridviewcolumnheader}"> <setter property="overridesdefaultstyle" value="true"/> <setter property="foreground" value="{staticresource headerforeground}"></setter> <setter property="template"> <setter.value> <controltemplate targettype="{x:type gridviewcolumnheader}"> <grid background="transparent" > <border padding="{templatebinding padding}"> <contentpresenter horizontalalignment="center" margin="5,4,1,3" verticalalignment="center" /> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="listviewstyle1" targettype="listview"> <setter property="itemcontainerstyle" value="{staticresource itemcontainerstyle1}"></setter> <setter property="alternationcount" value="2"/> <setter property="template"> <setter.value> <controltemplate targettype="listview"> <border background="transparent"> <grid> <grid.rowdefinitions> <rowdefinition height="40"/> <rowdefinition height="1*"/> </grid.rowdefinitions> <border cornerradius="3" borderthickness="{staticresource borderthickness}" borderbrush="{staticresource headerborderbrush}" background="{staticresource headerbackground}"> <gridviewheaderrowpresenter columns="{binding path=templatedparent.view.columns, relativesource={relativesource self}}" columnheadercontainerstyle="{staticresource columnheadercontainerstyle1}" allowscolumnreorder="{binding path=templatedparent.view.allowscolumnreorder, relativesource={relativesource self}}" snapstodevicepixels="{templatebinding snapstodevicepixels}" > </gridviewheaderrowpresenter> </border> <scrollviewer margin="0" grid.row="1"> <itemspresenter /> </scrollviewer> </grid> </border> </controltemplate> </setter.value> </setter> </style> <!--listview样式(2):带边框,奇偶行颜色不相同--> <style x:key="itemcontainerstyle2" targettype="{x:type listviewitem}" > <setter property="background" value="transparent"/> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <border background="{templatebinding background}" borderthickness="0 0 1 1" borderbrush="{staticresource bordercontent}"> <gridviewrowpresenter content="{templatebinding content}" columns="{templatebinding gridview.columncollection}" margin="-6 -3"/> </border> </controltemplate> </setter.value> </setter> <setter property="foreground" value="white"></setter> <setter property="fontsize" value="12" /> <setter property="height" value="40"/> <style.triggers> <trigger property="listview.alternationindex" value="0"> <setter property="background" value="#023746"/> </trigger> <trigger property="isselected" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> <trigger property="ismouseover" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> </style.triggers> </style> <style x:key="columnheadercontainerstyle2" targettype="{x:type gridviewcolumnheader}"> <setter property="overridesdefaultstyle" value="true"/> <setter property="foreground" value="#21ddfb"></setter> <setter property="template"> <setter.value> <controltemplate targettype="{x:type gridviewcolumnheader}"> <grid name="g" background="transparent" > <border name="bd" padding="{templatebinding padding}" borderthickness="0 0 1 0" borderbrush="{staticresource bordercontent}"> <contentpresenter horizontalalignment="center" verticalalignment="center" margin="-5 -3"/> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="listviewstyle2" targettype="listview"> <setter property="itemcontainerstyle" value="{staticresource itemcontainerstyle2}"></setter> <setter property="alternationcount" value="2"/> <setter property="template"> <setter.value> <controltemplate targettype="listview"> <border background="transparent"> <grid> <grid.rowdefinitions> <rowdefinition height="40"/> <rowdefinition height="1*"/> </grid.rowdefinitions> <border background="#034558" borderthickness="{staticresource borderthickness}" borderbrush="#087e85"> <gridviewheaderrowpresenter columns="{binding path=templatedparent.view.columns, relativesource={relativesource self}}" columnheadercontainerstyle="{staticresource columnheadercontainerstyle2}" allowscolumnreorder="{binding path=templatedparent.view.allowscolumnreorder, relativesource={relativesource self}}" snapstodevicepixels="{templatebinding snapstodevicepixels}" > </gridviewheaderrowpresenter> </border> <scrollviewer margin="0" grid.row="1"> <itemspresenter /> </scrollviewer> </grid> </border> </controltemplate> </setter.value> </setter> </style> <!--listview样式(3):无边框,奇偶行颜色不相同,菜单上使用--> <style x:key="itemcontainerstyle3" targettype="{x:type listviewitem}" > <setter property="background" value="transparent"/> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <border background="{templatebinding background}"> <gridviewrowpresenter content="{templatebinding content}" columns="{templatebinding gridview.columncollection}"/> </border> </controltemplate> </setter.value> </setter> <setter property="foreground" value="#1a1a1a"></setter> <setter property="fontsize" value="12" /> <setter property="margin" value="0" /> <setter property="height" value="30"/> <style.triggers> <trigger property="listview.alternationindex" value="0"> <setter property="background" value="#e8e0e8e8"/> </trigger> <trigger property="isselected" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> <trigger property="ismouseover" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> </style.triggers> </style> <style x:key="columnheadercontainerstyle3" targettype="{x:type gridviewcolumnheader}"> <setter property="overridesdefaultstyle" value="true"/> <setter property="foreground" value="#1a1a1a"></setter> <setter property="template"> <setter.value> <controltemplate targettype="{x:type gridviewcolumnheader}"> <grid name="g" > <border name="bd" padding="{templatebinding padding}" margin="5 0 5 0"> <contentpresenter verticalalignment="center" /> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="listviewstyle3" targettype="listview"> <setter property="itemcontainerstyle" value="{staticresource itemcontainerstyle3}"></setter> <setter property="alternationcount" value="2"/> <setter property="template"> <setter.value> <controltemplate targettype="listview"> <border> <grid> <grid.rowdefinitions> <rowdefinition height="40"/> <rowdefinition height="1*"/> </grid.rowdefinitions> <border borderthickness="0" cornerradius="2" margin="5 5 5 5" background="#ffffff"> <gridviewheaderrowpresenter columns="{binding path=templatedparent.view.columns, relativesource={relativesource self}}" columnheadercontainerstyle="{staticresource columnheadercontainerstyle3}" allowscolumnreorder="{binding path=templatedparent.view.allowscolumnreorder, relativesource={relativesource self}}" snapstodevicepixels="{templatebinding snapstodevicepixels}" > </gridviewheaderrowpresenter> </border> <scrollviewer grid.row="1" margin="5 0 5 0" horizontalscrollbarvisibility="hidden"> <itemspresenter /> </scrollviewer> </grid> </border> </controltemplate> </setter.value> </setter> </style> <!--listview样式(4):无边框,奇偶行颜色不相同,弹出窗口使用--> <style x:key="itemcontainerstyle4" targettype="{x:type listviewitem}" > <setter property="background" value="transparent"/> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <border background="{templatebinding background}"> <gridviewrowpresenter content="{templatebinding content}" columns="{templatebinding gridview.columncollection}"/> </border> </controltemplate> </setter.value> </setter> <setter property="foreground" value="black"></setter> <setter property="fontsize" value="12" /> <setter property="height" value="30"/> <style.triggers> <trigger property="listview.alternationindex" value="0"> <setter property="background" value="#eeeeee"/> </trigger> <trigger property="isselected" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> <trigger property="ismouseover" value="true"> <setter property="foreground" value="#ff5e5e"/> </trigger> </style.triggers> </style> <style x:key="columnheadercontainerstyle4" targettype="{x:type gridviewcolumnheader}"> <setter property="overridesdefaultstyle" value="true"/> <setter property="foreground" value="black"></setter> <setter property="template"> <setter.value> <controltemplate targettype="{x:type gridviewcolumnheader}"> <grid name="g" background="transparent" > <border name="bd" padding="{templatebinding padding}"> <contentpresenter horizontalalignment="center" margin="5,4,1,3" verticalalignment="center" /> </border> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="listviewstyle4" targettype="listview"> <setter property="itemcontainerstyle" value="{staticresource itemcontainerstyle4}"></setter> <setter property="alternationcount" value="2"/> <setter property="template"> <setter.value> <controltemplate targettype="listview"> <border background="transparent"> <grid> <grid.rowdefinitions> <rowdefinition height="30"/> <rowdefinition height="1*"/> </grid.rowdefinitions> <border background="#d6e5f1" borderthickness="{staticresource borderthickness}" borderbrush="#087e85" cornerradius="3"> <gridviewheaderrowpresenter columns="{binding path=templatedparent.view.columns, relativesource={relativesource self}}" columnheadercontainerstyle="{staticresource columnheadercontainerstyle4}" allowscolumnreorder="{binding path=templatedparent.view.allowscolumnreorder, relativesource={relativesource self}}" snapstodevicepixels="{templatebinding snapstodevicepixels}" > </gridviewheaderrowpresenter> </border> <scrollviewer margin="0" grid.row="1"> <itemspresenter /> </scrollviewer> </grid> </border> </controltemplate> </setter.value> </setter> </style> <!--datagrid样式:带边框,奇偶行颜色不相同--> <style x:key="defaultcolumnheadergripperstyle" targettype="{x:type thumb}"> <setter property="width" value="8" /> <setter property="background" value="{staticresource headerborderbrush}" /> <setter property="cursor" value="sizewe" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type thumb}"> <border padding="{templatebinding padding}" background="transparent" margin="0 0 0 2"> <rectangle horizontalalignment="{templatebinding horizontalcontentalignment}" width="1" fill="{templatebinding background}" /> </border> </controltemplate> </setter.value> </setter> </style> <style x:key="defaultdatagridcolumnheader" targettype="{x:type datagridcolumnheader}"> <setter property="snapstodevicepixels" value="true" /> <setter property="minwidth" value="5" /> <setter property="minheight" value="40" /> <setter property="height" value="40" /> <setter property="foreground" value="{staticresource headerforeground}" /> <setter property="horizontalcontentalignment" value="center" /> <setter property="verticalcontentalignment" value="center" /> <setter property="padding" value="10,4,4,7" /> <setter property="margin" value="0,0,0,0" /> <setter property="fontweight" value="semibold"></setter> <setter property="fontsize" value="12" /> <setter property="borderthickness" value="0,0,0,3" /> <setter property="borderbrush" value="{staticresource bordercontent}" /> <setter property="background" value="{staticresource headerbackground}" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type datagridcolumnheader}"> <grid> <grid.columndefinitions> <columndefinition width="*" /> <columndefinition width="auto" /> </grid.columndefinitions> <border x:name="backgroundborder" borderthickness="{templatebinding borderthickness}" grid.columnspan="2" background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" /> <contentpresenter x:name="headercontent" content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}" margin="{templatebinding padding}" verticalalignment="{templatebinding verticalcontentalignment}" horizontalalignment="{templatebinding horizontalcontentalignment}" recognizesaccesskey="true" snapstodevicepixels="{templatebinding snapstodevicepixels}" /> <textblock x:name="sortarrow" grid.column="1" width="20" visibility="collapsed" fontsize="16" margin="1,1,3,1" /> <thumb x:name="part_leftheadergripper" horizontalalignment="left" horizontalcontentalignment="left" style="{staticresource defaultcolumnheadergripperstyle}" /> <thumb x:name="part_rightheadergripper" horizontalalignment="right" horizontalcontentalignment="right" background="transparent" style="{staticresource defaultcolumnheadergripperstyle}" grid.column="1" /> </grid> <controltemplate.triggers> <!--显示排序标示--> <multitrigger> <multitrigger.conditions> <condition property="ismouseover" value="true" /> <condition property="sortdirection" value="{x:null}" /> <condition property="canusersort" value="true" /> </multitrigger.conditions> <setter targetname="sortarrow" property="visibility" value="visible" /> </multitrigger> <!--可排序列鼠标样式--> <trigger property="canusersort" value="true"> <setter property="cursor" value="hand"></setter> </trigger> <!--升序--> <trigger property="sortdirection" value="ascending"> <setter targetname="sortarrow" property="visibility" value="visible" /> </trigger> <!--降序--> <trigger property="sortdirection" value="descending"> <setter targetname="sortarrow" property="visibility" value="visible" /> <setter targetname="sortarrow" property="text" value=""/> </trigger> <!--第一列左边不显示分割线--> <trigger property="displayindex" value="2"> <setter property="visibility" value="collapsed" targetname="part_leftheadergripper" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <style x:key="defaultdatagridrow" targettype="{x:type datagridrow}"> <setter property="foreground" value="{staticresource textforeground}" /> <setter property="background" value="transparent" /> <setter property="margin" value="0,0,0,0" /> <style.triggers> <trigger property="alternationindex" value="0" > <setter property="background" value="{staticresource itemsalternationindexbackground0}" /> </trigger> <trigger property="alternationindex" value="1" > <setter property="background" value="{staticresource itemsalternationindexbackground1}" /> </trigger> <trigger property="isselected" value="true"> <setter property="background" value="{staticresource itemselectedbackground}" /> <setter property="foreground" value="{staticresource itemselectedforeground}" /> </trigger> <multitrigger> <multitrigger.conditions> <condition property="isselected" value="true" /> <condition property="selector.isselectionactive" value="true" /> </multitrigger.conditions> <setter property="background" value="{staticresource itemselectedbackground}" /> <setter property="foreground" value="{staticresource itemselectedforeground}" /> </multitrigger> <multidatatrigger> <multidatatrigger.conditions> <condition binding="{binding path=ismouseover, relativesource={relativesource self}}" value="true" /> </multidatatrigger.conditions> <setter property="background" value="{staticresource itemmouseoverbackground}" /> <setter property="foreground" value="{staticresource itemmouseoverforeground}" /> </multidatatrigger> </style.triggers> </style> <style x:key="defaultrowheadergripperstyle" targettype="{x:type thumb}"> <setter property="height" value="6" /> <setter property="background" value="transparent" /> <setter property="cursor" value="sizens" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type thumb}"> <border padding="{templatebinding padding}" background="transparent"/> </controltemplate> </setter.value> </setter> </style> <style x:key="defaultdatagridrowheader" targettype="{x:type datagridrowheader}"> <setter property="horizontalcontentalignment" value="stretch" /> <setter property="verticalcontentalignment" value="center" /> <setter property="background" value="transparent" /> <setter property="borderbrush" value="transparent" /> <setter property="borderthickness" value="0,0,1,0" /> <setter property="margin" value="0,0,0,0" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type datagridrowheader}"> <grid> <border borderbrush="{templatebinding borderbrush}" background="{templatebinding background}" borderthickness="{templatebinding borderthickness}" padding="{templatebinding padding}" margin="{templatebinding margin}" snapstodevicepixels="true"> <contentpresenter snapstodevicepixels="{templatebinding snapstodevicepixels}" verticalalignment="{templatebinding verticalcontentalignment}" horizontalalignment="{templatebinding horizontalcontentalignment}"/> </border> <thumb x:name="part_topheadergripper" verticalcontentalignment="top" verticalalignment="top" background="transparent" style="{staticresource defaultrowheadergripperstyle}" /> <thumb x:name="part_bottomheadergripper" verticalcontentalignment="bottom" verticalalignment="bottom" style="{staticresource defaultrowheadergripperstyle}" /> </grid> </controltemplate> </setter.value> </setter> </style> <style x:key="defaultdatagridcell" targettype="{x:type datagridcell}"> <setter property="background" value="transparent" /> <setter property="borderbrush" value="transparent" /> <setter property="horizontalcontentalignment" value="stretch" />
赞 (0)
打赏
微信扫一扫
相关文章:
-
-
Java集合系列文章将以思维导图为主要形式来展示知识点,让零碎的知识形成体系。 这篇文章主要介绍的是【Java 集合的基本知识】,即Java 集合简... [阅读全文]
-
盗版当然不会消失,小打小闹的资源网站、公号、网盘依然存在,不过前提是什么,底线是什么,一目了然。 [阅读全文]
-
网站优化是一件非常系统化的工作,而且网站优化也是非常讲究策略和方法的!如何安排好自己每天的工作任务和计划便成了做好网站优化的头等大事!下面小李子给大家分享一些自... [阅读全文]
-
MyBatis3系列__05查询补充&resultMap与resultType区别
1.查询补充 当你查询一条记录并且是简单查询时,情况相对简单,可以参考以下的例子: 对应的xml文件中: 当查询多条记录时,可以参考以下方式:、 x... [阅读全文] -
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论