slider value changed event : Slider « Windows Presentation Foundation « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » Slider 
16.23.9.slider value changed event
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="200" Width="300">
    <StackPanel>
        <TextBlock Margin="5" Text="0" FontSize="20" 
                   HorizontalAlignment="Center" Name="txtSliderValue" />
        <Slider LargeChange="10" Margin="5" Maximum="1000" Minimum="0" 
                Name="slider1" TickPlacement="TopLeft" 
                Ticks="100, 200, 400, 800" Value="0"
                ValueChanged="slider_ValueChanged" />
        <Button Name="btnGetSliderValue1" Width="100" 
                Click="GetSliderValue_Click">Get Slider Value</Button>
        <Slider IsSnapToTickEnabled="True" Margin="5" Maximum="1000" 
                Minimum="0" Name="slider2" TickFrequency="25" 
                TickPlacement="BottomRight" Value="1000" 
                ValueChanged="slider_ValueChanged" />
        <Button Name="btnGetSliderValue2" Width="100" 
                Click="GetSliderValue_Click">Get Slider Value</Button>
    </StackPanel>
</Window>
//File:Window.xaml.vb
Imports System.Windows
Imports System.Windows.Controls

Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub
    Private Sub GetSliderValue_Click(sender As Object, e As RoutedEventArgs)
      Dim button As Button = TryCast(e.OriginalSource, Button)
      Dim message As String = "Unknown slider."

      If button Is btnGetSliderValue1 Then
        message = "Slider1 value = " + slider1.Value
      ElseIf button Is btnGetSliderValue2 Then
        message = "Slider2 value = " + slider2.Value
      End If

      MessageBox.Show(message, Title)
    End Sub
    Private Sub slider_ValueChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of Double))
      Dim slider As Slider = TryCast(e.OriginalSource, Slider)

      If slider IsNot Nothing Then
        txtSliderValue.Text = slider.Value.ToString()
      End If
    End Sub
  End Class
End Namespace
WPF Slider Value Changed Event
16.23.Slider
16.23.1.Slider with Tick Marks (TickFrequency=10, TickPlacement=BottomRight)Slider with Tick Marks (TickFrequency=10, TickPlacement=BottomRight)
16.23.2.Slider with Irregular Tick Marks (Ticks=0,5,10,15,25,50,100)Slider with Irregular Tick Marks (Ticks=0,5,10,15,25,50,100)
16.23.3.Slider with a Selection Range (IsSelectionRangeEnabled=True, SelectionStart=25, SelectionEnd=75)Slider with a Selection Range (IsSelectionRangeEnabled=True, SelectionStart=25, SelectionEnd=75)
16.23.4.Use Slider to scale a LineUse Slider to scale a Line
16.23.5.Use Slider to scale a RectangleUse Slider to scale a Rectangle
16.23.6.Use Slider to Control LabelUse Slider to Control Label
16.23.7.Slider AttributesSlider Attributes
16.23.8.Get User Input from a SliderGet User Input from a Slider
16.23.9.slider value changed eventslider value changed event
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.