![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| audio slider/mixer do not work | Sound & Audio | |||
| Volume slider drops to Zero | Vista hardware & devices | |||