Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Slider Control Styling

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-13-2006   #1 (permalink)
Jobi Joy
Guest


 

Slider Control Styling

Does any body have a control template / style overridden for Slider
control?
My intension is to draw a small rectangle from the left side to the
Thumb point while user changes Slider value. The background will be
another rectangular area,
When I use my Arrow keys I am getting the ValueChange Event from the
following code. I wanted to have the mouse click ability also on the
slider.

<Style TargetType="{x:Type Slider}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Slider}">
<Canvas Name="Canvas" Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Background="{TemplateBinding Background}"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
MaxHeight="{TemplateBinding MaxHeight}">
</Canvas>
<ControlTemplate.Triggers>
<Trigger Property="Slider.IsMouseOver" Value="True">
<Setter Property = "Background" Value="Green"/>
<Setter Property = "TickPlacement" Value ="TopLeft"/>
<Setter Property = "IsMoveToPointEnabled" Value
="True"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>


My System SpecsSystem Spec
Old 10-13-2006   #2 (permalink)
Jobi Joy
Guest


 

Re: Slider Control Styling

Hi guys,
I just finished the styling of slider as I wanted using the
information from MSDN at
http://windowssdk.msdn.microsoft.com...56(VS.80).aspx

Here is my slider code.

<Window.Resources>
<ControlTemplate x:Key="HorizontalSlider" TargetType="{x:Type
Slider}">
<Canvas>
<Canvas.Background>
<LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset="0.03"/>
<GradientStop Color="AliceBlue" Offset="0.4"/>
<GradientStop Color="DarkSlateGray" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Canvas.Background>
<Track x:Name="PART_Track" Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}">
<Track.DecreaseRepeatButton>
<RepeatButton Command="Slider.DecreaseLarge" Opacity="0.9">
<RepeatButton.BitmapEffect>
<BevelBitmapEffect BevelWidth="2"
EdgeProfile="CurvedIn" LightAngle="3" />
</RepeatButton.BitmapEffect>
<RepeatButton.Background>
<LinearGradientBrush StartPoint="1,1" EndPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.1" Color="Black"/>
<GradientStop Offset="0.7" Color="AliceBlue"/>
<GradientStop Offset="1" Color="DarkSlateGray"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</RepeatButton.Background>
</RepeatButton>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb x:Name="Thumb" Height="{TemplateBinding Height}"
Width="0"/>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Command="Slider.IncreaseLarge" Opacity="0"/>
</Track.IncreaseRepeatButton>
</Track>
</Canvas>
</ControlTemplate>

</Window.Resources>
<Slider Template="{StaticResource HorizontalSlider}" Value="3"
Height="33" Width="300" Name="Slider" Minimum="0"
Maximum="10" SmallChange="1" Background="Blue"
ToolTipService.Placement="MousePoint" ToolTip="{Binding
ElementName=Slider,Path=Value}"
IsMoveToPointEnabled="True" VerticalAlignment="Top"
Margin="16,27,21,0" Grid.ColumnSpan="1"/>





On Oct 13, 2:39 pm, "Jobi Joy" <jobi....@gmail.com> wrote:
> Does any body have a control template / style overridden for Slider
> control?
> My intension is to draw a small rectangle from the left side to the
> Thumb point while user changes Slider value. The background will be
> another rectangular area,
> When I use my Arrow keys I am getting the ValueChange Event from the
> following code. I wanted to have the mouse click ability also on the
> slider.
>
> <Style TargetType="{x:Type Slider}">
> <Setter Property="Template">
> <Setter.Value>
> <ControlTemplate TargetType="{x:Type Slider}">
> <Canvas Name="Canvas" Width="{TemplateBinding Width}"
> Height="{TemplateBinding Height}"
> Background="{TemplateBinding Background}"
> MinWidth="{TemplateBinding MinWidth}"
> MinHeight="{TemplateBinding MinHeight}"
> MaxHeight="{TemplateBinding MaxHeight}">
> </Canvas>
> <ControlTemplate.Triggers>
> <Trigger Property="Slider.IsMouseOver" Value="True">
> <Setter Property = "Background" Value="Green"/>
> <Setter Property = "TickPlacement" Value ="TopLeft"/>
> <Setter Property = "IsMoveToPointEnabled" Value
> ="True"/>
> </Trigger>
> </ControlTemplate.Triggers>
> </ControlTemplate>
> </Setter.Value>
> </Setter>
> </Style>


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Volume slider drops to Zero doboy Vista hardware & devices 1 06-20-2007 06:09 PM
How to determine index of TabItem when styling Tab =?Utf-8?B?TmVhbCBCb3JlbGxp?= Avalon 0 08-15-2006 07:32 PM
Binding a value display for a slider? Doug Brown Avalon 0 07-18-2006 07:53 AM
Styling the scroll bar Philippe Lavoie Avalon 1 05-10-2006 12:03 PM
Slider control use Jason Dolinger Avalon 2 01-10-2006 03:54 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51