Bind Slider value to TextBlock : Slider Data Binding « Windows Presentation Foundation « C# / CSharp Tutorial






<Window  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SDKSample.Pane1">

    <StackPanel>
      <TextBlock Margin="0,10,0,0"  Foreground="Blue">
      <TextBlock Text="(Height,Width) = "/>
      <TextBlock Text="{Binding ElementName=RectangleHeight,Path=Value}"/>
      ,
      <TextBlock Text="{Binding ElementName=RectangleWidth,Path=Value}"/>
    </TextBlock>

    <TextBlock Margin="10,10,0,0">Height</TextBlock>
    <Slider Name="RectangleHeight"  Margin="10, 0, 0, 0" 
      Width="100" Orientation="Horizontal" HorizontalAlignment="Left" 
      Value="50" Minimum="0" Maximum="200" 
      SmallChange="1" LargeChange="10"
      TickPlacement="BottomRight" TickFrequency="10"/>
    <TextBlock Margin="10,0,0,0">Width</TextBlock>
    <Slider Name="RectangleWidth" Margin="10, 0, 0, 0" 
      Width="100" Orientation="Horizontal" HorizontalAlignment="Left" 
      Value="50" Minimum="0" Maximum="200"
      SmallChange="1" LargeChange="10"
      TickPlacement="BottomRight" TickFrequency="10"/>
        <Rectangle Fill="Blue" HorizontalAlignment="Left" 
               Margin="50,20,0,0" 
               Height="{Binding ElementName=RectangleHeight,Path=Value}" 
               Width="{Binding ElementName=RectangleWidth,Path=Value}"/>
    </StackPanel>

</Window>
WPF Bind Slider Value To Text Block








24.27.Slider Data Binding
24.27.1.Use Slider to control the ScaleTransformUse Slider to control the ScaleTransform
24.27.2.Use Slider to control SkewTransformUse Slider to control SkewTransform
24.27.3.Use Slider to control TranslateTransformUse Slider to control TranslateTransform
24.27.4.Use Slider to control the TransformationUse Slider to control the Transformation
24.27.5.Bind Slider value to TextBlockBind Slider value to TextBlock
24.27.6.Use Slider to control the BlurUse Slider to control the Blur
24.27.7.Use Slider to control Drop ShadowUse Slider to control Drop Shadow
24.27.8.Use Slider to control the EmbossUse Slider to control the Emboss
24.27.9.Use Slider to control the GlowUse Slider to control the Glow
24.27.10.Use Slider to control the BevelUse Slider to control the Bevel
24.27.11.Binding ProgressBar with SliderBinding ProgressBar with Slider
24.27.12.Two way data binding between Slider and ProgressBarTwo way data binding between Slider and ProgressBar
24.27.13.Use Slider to control Path ScalingUse Slider to control Path Scaling