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 use

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
Jason Dolinger
Guest


 

Slider control use

Can anyone explain to me how I'm supposed to use the slider to actually
connect it to another control or objects property? The Windows SDK
sample and the Sells book only show how to place the Slider on your
form, but not actually use it to do anything! I'd like to use a slider
to resize my window...

Thanks,
Jason
Old 01-10-2006   #2 (permalink)
Jason Dolinger
Guest


 

Re: Slider control use

Jason Dolinger wrote:
> Can anyone explain to me how I'm supposed to use the slider to actually
> connect it to another control or objects property? The Windows SDK
> sample and the Sells book only show how to place the Slider on your
> form, but not actually use it to do anything! I'd like to use a slider
> to resize my window...
>
> Thanks,
> Jason


Ok, I think I originally misunderstood, it's really the property that
you want to set that is hooked up to the value of the slider. First you
handle the slider's ValueChanged event in your XAML:

<Slider ValueChanged="OnSliderValueChanged" />


In the code behind file, implement that method to set your property to
the current value of the slider:

public void OnSliderValueChanged(object sender,
RoutedPropertyChangedEventArgs<double> e)
{
Console.WriteLine(scaler.Value);
Height = scaler.Value; // this could be any other property
}



However, is this really necessary? I'd love to see some syntactic sugar
that would just directly allow you to directly hook an objects property
to the slider. It's a pain to have to put the event handling code in
here. I can't think of a scenario where you use a slider where you
wouldn't be handling the ValueChanged event, so why not provide a shortcut?

Jason
Old 01-10-2006   #3 (permalink)
Tina Tam [MSFT]
Guest


 

Re: Slider control use

This Slider controls the Width of the Button:
<Grid>

<Button Name="btn" Width="50" Height="50">Test</Button>

<Slider Value="{Binding ElementName=btn, Path=Width}" Minimum="50"
Maximum="300"/>

</Grid>

Hope that helps you get started,

Tina

"Jason Dolinger" <jdolinger@lab49.com> wrote in message
news:OEQ%232wiEGHA.2544@TK2MSFTNGP11.phx.gbl...
> Jason Dolinger wrote:
>> Can anyone explain to me how I'm supposed to use the slider to actually
>> connect it to another control or objects property? The Windows SDK
>> sample and the Sells book only show how to place the Slider on your form,
>> but not actually use it to do anything! I'd like to use a slider to
>> resize my window...
>>
>> Thanks,
>> Jason

>
> Ok, I think I originally misunderstood, it's really the property that you
> want to set that is hooked up to the value of the slider. First you
> handle the slider's ValueChanged event in your XAML:
>
> <Slider ValueChanged="OnSliderValueChanged" />
>
>
> In the code behind file, implement that method to set your property to the
> current value of the slider:
>
> public void OnSliderValueChanged(object sender,
> RoutedPropertyChangedEventArgs<double> e)
> {
> Console.WriteLine(scaler.Value);
> Height = scaler.Value; // this could be any other property
> }
>
>
>
> However, is this really necessary? I'd love to see some syntactic sugar
> that would just directly allow you to directly hook an objects property to
> the slider. It's a pain to have to put the event handling code in here.
> I can't think of a scenario where you use a slider where you wouldn't be
> handling the ValueChanged event, so why not provide a shortcut?
>
> Jason



Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
No Sound Acceleration Slider on DXDiag Mattjesty Vista hardware & devices 0 08-26-2007 05:10 AM
Volume slider drops to Zero doboy Vista hardware & devices 1 06-20-2007 06:09 PM
Slider Control Styling Jobi Joy Avalon 1 10-13-2006 08:17 AM
Binding a value display for a slider? Doug Brown Avalon 0 07-18-2006 07:53 AM
Questions on Slider.ValueChanged Nick Howell Avalon 0 03-19-2006 02:04 AM








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