![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 |
| | #2 (permalink) |
| 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 |
| | #3 (permalink) |
| 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 |
| |
| |
![]() |
| 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 |