c# - Change default highlight colour of TabItem in TabControl WPF -
im trying change default highlight colour of tab item in tab control in wpf.
in image highlight colour orange, want know if there away change solid colour?
here xaml declares tabcontrol , 2 tabitems
<tabcontrol> <tabcontrol.background> <lineargradientbrush endpoint="0,1" startpoint="0,0"> <gradientstop color="#ffccccd0"/> <gradientstop color="#ff526593" offset="1"/> </lineargradientbrush> </tabcontrol.background> <tabitem header="test1"> <tabitem.content> <stackpanel orientation="horizontal"> <button content="test" verticalalignment="center" /> <button content="test2" /> </stackpanel> </tabitem.content> </tabitem> <tabitem header="test2"> <tabitem.content> <textbox /> </tabitem.content> </tabitem> </tabcontrol>
please note dont have access expression blend, solutions need possible in visual studio 2010.
thanks.
you need override style of tabitem control. below example still needs tweaking. change style want. isselected trigger adds changes tabitem when selected.
<window.resources> <resourcedictionary> <style targettype="{x:type tabitem}"> <setter property="borderthickness" value="3" /> <setter property="borderbrush" value="blue" /> <setter property="verticalcontentalignment" value="center" /> <setter property="horizontalcontentalignment" value="center" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type tabitem}"> <border> <grid> <grid> <border x:name="border" cornerradius="3,3,0,0" background="{templatebinding background}" borderbrush="{templatebinding borderbrush}" borderthickness="1,1,1,0" /> </grid> <border borderthickness="{templatebinding borderthickness}" padding="{templatebinding padding}"> <contentpresenter contentsource="header" horizontalalignment="{templatebinding horizontalcontentalignment}" verticalalignment="{templatebinding verticalcontentalignment}" /> </border> </grid> </border> <controltemplate.triggers> <trigger property="isselected" value="true"> <setter targetname="border" property="borderbrush" value="red" /> <setter targetname="border" property="borderthickness" value="0,3,0,0" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> </resourcedictionary> </window.resources> <grid> <tabcontrol> <tabcontrol.background> <lineargradientbrush endpoint="0,1" startpoint="0,0"> <gradientstop color="#ffccccd0" /> <gradientstop color="#ff526593" offset="1" /> </lineargradientbrush> </tabcontrol.background> <tabitem header="test1"> <tabitem.content> <stackpanel orientation="horizontal"> <button content="test" verticalalignment="center" /> <button content="test2" /> </stackpanel> </tabitem.content> </tabitem> <tabitem header="test2"> <tabitem.content> <textbox /> </tabitem.content> </tabitem> </tabcontrol> </grid>
Comments
Post a Comment