xaml - WPF Slider looks different in Visual studio and in app -
i have strange behavior. in wpf app have slider wanted change background color. made resource dictionary file , overwrite template
in visual studio slider looks fine: that shown in ide
but when start app see normal default slider: how looks when start app
what wrong?
i added customslider.xaml file in app.xaml this:
<resourcedictionary.mergeddictionaries> <resourcedictionary source="./customslider.xaml" /> </resourcedictionary.mergeddictionaries>
and slide defined as:
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:xxxxx.ui"> <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> <style x:key="sliderthumbstyle" targettype="{x:type thumb}"> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="false" /> <setter property="height" value="50" /> <setter property="background" value="black" /> <setter property="width" value="50" /> </style> <!--template when orientation of slider horizontal.--> <controltemplate x:key="horizontalslider" targettype="{x:type slider}"> <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="auto" minheight="{templatebinding minheight}" /> <rowdefinition height="auto" /> </grid.rowdefinitions> <border x:name="trackbackground" margin="0" cornerradius="2" height="50" grid.row="1" borderthickness="1"> <border.background> <lineargradientbrush endpoint="0,0" startpoint="1,0"> <lineargradientbrush.gradientstops> <gradientstopcollection> <gradientstop color="red" offset="0" /> <gradientstop color="yellow" offset="0.5" /> <gradientstop color="green" offset="1" /> </gradientstopcollection> </lineargradientbrush.gradientstops> </lineargradientbrush> </border.background> </border> <track grid.row="1" 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> </grid> </controltemplate> <style targettype="{x:type slider}"> <setter property="snapstodevicepixels" value="true" /> <setter property="overridesdefaultstyle" value="true" /> <style.triggers> <trigger property="orientation" value="horizontal"> <setter property="template" value="{staticresource horizontalslider}" /> </trigger> </style.triggers> </style>
edited (added):
<slider horizontalalignment="center" ismovetopointenabled="true" thumb.dragstarted="valuechangedragstart" thumb.dragcompleted="valuechangedragend" maximum="100" minimum="-100" name="volumeslider" valuechanged="valuechanged" width="490" issnaptotickenabled="true" tickfrequency="1" margin="0,-18,0,0"> </slider>
Comments
Post a Comment