Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Slider control use

 
 
Old 01-10-2006   #1 (permalink)
Jason Dolinger


 
 

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

My System SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
Jason Dolinger


 
 

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
My System SpecsSystem Spec
Old 01-10-2006   #3 (permalink)
Tina Tam [MSFT]


 
 

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



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
audio slider/mixer do not work Sound & Audio
Volume slider drops to Zero Vista hardware & devices


Vista Forums 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 Ltd

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