WPF learning path (12) control (Range control), wpfrange
ProgressBar
Progress bar. The main attribute is Minimum \ Maximun \ Value. If IsIndeterminate is True, the progress bar runs cyclically.
<Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <StackPanel Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Center"> <ProgressBar Name="pb1" Height="20" Width="200" Foreground="LightBlue" IsIndeterminate="True"></ProgressBar> </StackPanel> <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"> <ProgressBar Name="pb2" Height="20" Width="200" Foreground="LightBlue"></ProgressBar> <Button Name="btn" MaxWidth="50" Margin="5" Click="BTN_Click">Start</Button> </StackPanel></Grid>
private void BTN_Click(object sender, RoutedEventArgs e){ Duration duration = new Duration(TimeSpan.FromSeconds(10)); DoubleAnimation doubleAnimation = new DoubleAnimation(100, duration); pb2.BeginAnimation(ProgressBar.ValueProperty, doubleAnimation);}
More
Http://www.codeproject.com/Articles/38555/WPF-ProgressBar
Http://blog.csdn.net/tcjiaan/article/details/6963687
Silder
A very common slider. The widget displays a series of scale values and a slider that can be dragged. You can drag the slider to control the value of the widget.
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Rectangle Grid.Column="0" x:Name="rect" Fill="Black"></Rectangle> <StackPanel Grid.Column="1"> <StackPanel Orientation="Horizontal" Margin="10,2,5,2" > <TextBlock Text="R" Margin="5,1,1,1" VerticalAlignment="Center"></TextBlock> <Slider Name="RSlider" Margin="5" Minimum="0" Maximum="255" TickFrequency="10" Ticks="0,50,100,150,200,250" TickPlacement="BottomRight" IsSnapToTickEnabled="False" ValueChanged="RSlider_ValueChanged" MinWidth="220"></Slider> </StackPanel> <StackPanel Orientation="Horizontal" Margin="10,2,5,2" > <TextBlock Text="G" Margin="5,1,1,1" VerticalAlignment="Center"></TextBlock> <Slider Name="GSlider" Margin="5" Minimum="0" Maximum="255" TickFrequency="10" Ticks="0,50,100,150,200,250" TickPlacement="BottomRight" IsSnapToTickEnabled="False" ValueChanged="GSlider_ValueChanged" MinWidth="220"></Slider> </StackPanel> <StackPanel Orientation="Horizontal" Margin="10,2,5,2" > <TextBlock Text="B" Margin="5,1,1,1" VerticalAlignment="Center"></TextBlock> <Slider Name="BSlider" Margin="5" Minimum="0" Maximum="255" TickFrequency="10" Ticks="0,50,100,150,200,250" TickPlacement="BottomRight" IsSnapToTickEnabled="False" ValueChanged="BSlider_ValueChanged" MinWidth="220"></Slider> </StackPanel> </StackPanel></Grid>
private void RSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { Update(); } private void BSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { Update(); } private void GSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { Update(); } private void Update() { Color color = Color.FromRgb(Convert.ToByte(RSlider.Value), Convert.ToByte(BSlider.Value), Convert.ToByte(GSlider.Value)); rect.Fill = new SolidColorBrush(color); }
More
Http://blog.csdn.net/tcjiaan/article/details/6997900
To be continue...