wpf - Why is my custom Slider not visible at design time? -
i have used this page msdn apply custom style slider control. works @ run-time shown in image below, @ design time, entire slider control not visible (hidden/collapsed??). how can slider visible @ design time?
slider @ run-time:
the xaml showing implementation of custom slider on wpf window:
<slider grid.column="1" style="{staticresource sldgradeability}" orientation="vertical" name="sldgrade" maximum="90" minimum="0" smallchange="1" largechange="10" margin="5,20,10,20"/>
the xaml custom slider style:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!--<snippetslider>--> <style x:key="sliderbuttonstyle" targettype="{x:type repeatbutton}"> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="true" /> <setter property="istabstop" value="false" /> <setter property="focusable" value="false" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type repeatbutton}"> <border background="transparent" /> </controltemplate> </setter.value> </setter> </style> <!--<snippetthumb>--> <style x:key="sliderthumbstyle" targettype="{x:type thumb}"> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="true" /> <setter property="height" value="16" /> <setter property="width" value="25" /> <setter property="template"> <setter.value> <controltemplate targettype="{x:type thumb}"> <polygon x:name="polythumb" cursor="hand" strokethickness="1" points="0,8 6,16 24,16 24,0 6,0" stroke="{staticresource brsdarkgraytext}" fill="{staticresource buttonnormal}"/> <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="polythumb" property="fill" value="{staticresource buttonover}" /> </trigger> <trigger property="isdragging" value="true"> <setter targetname="polythumb" property="fill" value="{staticresource buttondown}" /> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!--template when orientation of slider vertical.--> <controltemplate x:key="verticalslider" targettype="{x:type slider}"> <grid> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="auto" /> <columndefinition width="auto" /> <columndefinition width="auto" /> </grid.columndefinitions> <grid grid.column="0"> <grid.rowdefinitions> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> <rowdefinition height="1*"/> </grid.rowdefinitions> <textblock grid.row="0" text="90°" style="{staticresource simpletextright}"/> <textblock grid.row="1" text="80°" style="{staticresource simpletextright}"/> <textblock grid.row="2" text="70°" style="{staticresource simpletextright}"/> <textblock grid.row="3" text="60°" style="{staticresource simpletextright}"/> <textblock grid.row="4" text="50°" style="{staticresource simpletextright}"/> <textblock grid.row="5" text="40°" style="{staticresource simpletextright}"/> <textblock grid.row="6" text="30°" style="{staticresource simpletextright}"/> <textblock grid.row="7" text="20°" style="{staticresource simpletextright}"/> <textblock grid.row="8" text="10°" style="{staticresource simpletextright}"/> <textblock grid.row="9" text="0°" style="{staticresource simpletextright}"/> </grid> <tickbar grid.column="1" x:name="toptick" snapstodevicepixels="true" placement="left" width="5" visibility="visible" tickfrequency="10" fill="{staticresource brsdarkgraytext}"/> <border x:name="trackbackground" margin="0" cornerradius="2" width="5" grid.column="2" borderthickness="0"> <border.background> <lineargradientbrush endpoint="1,0" startpoint="0,0"> <gradientstop color="{staticresource lightgraygradient}" offset="0" /> <gradientstop color="{staticresource mediumgraygradient}" offset="1" /> </lineargradientbrush> </border.background> </border> <track grid.column="2" x:name="part_track"> <track.decreaserepeatbutton> <repeatbutton style="{staticresource sliderbuttonstyle}" command="slider.decreaselarge" /> </track.decreaserepeatbutton> <track.thumb> <thumb style="{staticresource sliderthumbstyle}" /> </track.thumb> <track.increaserepeatbutton> <repeatbutton style="{staticresource sliderbuttonstyle}" command="slider.increaselarge" /> </track.increaserepeatbutton> </track> <tickbar x:name="bottomtick" snapstodevicepixels="true" grid.column="3" fill="{staticresource brsdarkgraytext}" placement="right" width="4" visibility="collapsed" /> </grid> <controltemplate.triggers> <trigger property="tickplacement" value="topleft"> <setter targetname="toptick" property="visibility" value="visible" /> </trigger> <trigger property="tickplacement" value="bottomright"> <setter targetname="bottomtick" property="visibility" value="visible" /> </trigger> <trigger property="tickplacement" value="both"> <setter targetname="toptick" property="visibility" value="visible" /> <setter targetname="bottomtick" property="visibility" value="visible" /> </trigger> </controltemplate.triggers> </controltemplate> <!--slider control--> <style x:key="sldgradeability" targettype="{x:type slider}"> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="true" /> <setter property="visibility" value="visible"/> <style.triggers> <trigger property="orientation" value="vertical"> <setter property="minwidth" value="21" /> <setter property="minheight" value="104" /> <setter property="template" value="{staticresource verticalslider}" /> </trigger> </style.triggers> </style> <!--</snippetslider>--> </resourcedictionary>
it shows fine in blend 4 think bug in vs2010 designer somehow. anyway, problem seems orientation vertical trigger.
<style x:key="sldgradeability" targettype="{x:type slider}"> <!-- ... --> <style.triggers> <!-- ... --> <trigger property="orientation" value="vertical"> <setter property="template" value="{staticresource verticalslider}" /> </trigger> </style.triggers> </style>
moving template setter among setters , slider shows in designer
<style x:key="sldgradeability" targettype="{x:type slider}"> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="true" /> <setter property="visibility" value="visible"/> <setter property="template" value="{staticresource verticalslider}"/> <style.triggers> <trigger property="orientation" value="vertical"> <setter property="minwidth" value="21" /> <setter property="minheight" value="104" /> </trigger> </style.triggers> </style>
moving setter may not want here maybe can make use of somehow
Comments
Post a Comment