ProgressBar with infinite iterations

image_pdfimage_print


   
  


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ProgBar.Window1"
    Title ="ProgressBar"
    Width="500">

  <StackPanel>
    <Button Content="One" Click="MakeOne"/>
    <StatusBar Name="sbar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom" Background="Beige" >
      <StatusBarItem>
        <TextBlock>StatusBar</TextBlock>
      </StatusBarItem>
    </StatusBar>
  </StackPanel>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;



namespace ProgBar
{

    public partial class Window1 : Window
    {
        
        private void MakeOne(object sender, RoutedEventArgs e)
        {
           sbar.Items.Clear();
           Label lbl = new Label();
           lbl.Background = new LinearGradientBrush(Colors.LightBlue,        
                                                    Colors.SlateBlue, 90);
           lbl.Content = "ProgressBar with infinite iterations.";
           sbar.Items.Add(lbl);
           ProgressBar progbar = new ProgressBar();
           progbar.Width = 150;
           progbar.Height = 15;
           Duration duration = new Duration(TimeSpan.FromSeconds(1));
           DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);
           doubleanimation.RepeatBehavior = RepeatBehavior.Forever;
           progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
           sbar.Items.Add(progbar);
        } 
     }
}

   
    
     


Indeterminate ProgressBar

image_pdfimage_print


   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ProgBar.Window1"
    Title ="ProgressBar"
    Width="500">

  <StackPanel>
    <Button Content="One" Click="MakeOne"/>
    <StatusBar Name="sbar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom" Background="Beige" >
      <StatusBarItem>
        <TextBlock>StatusBar</TextBlock>
      </StatusBarItem>
    </StatusBar>
  </StackPanel>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;



namespace ProgBar
{

    public partial class Window1 : Window
    {
        
        private void MakeOne(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
             Label lbl = new Label();
             lbl.Background = new LinearGradientBrush(Colors.Pink, Colors.Red, 90);
             lbl.Content = "Indeterminate ProgressBar.";
             sbar.Items.Add(lbl);
             //<Snippet3>
             ProgressBar progbar = new ProgressBar();
             progbar.Background = Brushes.Gray;
             progbar.Foreground = Brushes.Red;
             progbar.Width = 150;
             progbar.Height = 15;
             progbar.IsIndeterminate = true;
             //</Snippet3>
             sbar.Items.Add(progbar);
        } 
     }
}

   
    
     


RadialGradientBrush Opacity from 1 to 0

image_pdfimage_print


   
  

<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
    <Window.Resources>
        <GradientStopCollection x:Key="myGradientStops">
      <GradientStop Color="Blue" Offset="0.0" />
      <GradientStop Color="Black" Offset="0.5" />
      <GradientStop Color="Transparent" Offset="1.0" />
    </GradientStopCollection>
    </Window.Resources>
    <StackPanel>
    <Rectangle Width="100" Height="50" Stroke="Black" StrokeThickness="1">
      <Rectangle.Fill>
        <RadialGradientBrush GradientStops="{StaticResource myGradientStops}" Opacity="1.0" />
      </Rectangle.Fill>
    </Rectangle>
    <Rectangle Width="100" Height="50" Stroke="Black" StrokeThickness="1" >
      <Rectangle.Fill>
        <RadialGradientBrush GradientStops="{StaticResource myGradientStops}" Opacity="0.75" />
      </Rectangle.Fill>
    </Rectangle>
    <Rectangle Width="100" Height="50" Stroke="Black" StrokeThickness="1">
      <Rectangle.Fill>
        <RadialGradientBrush GradientStops="{StaticResource myGradientStops}" Opacity="0.5" />
      </Rectangle.Fill>
    </Rectangle>
    <Rectangle Width="100" Height="50" Stroke="Black" StrokeThickness="1">
      <Rectangle.Fill>
        <RadialGradientBrush GradientStops="{StaticResource myGradientStops}" Opacity="0.25" />
      </Rectangle.Fill>
    </Rectangle>
    <Rectangle Width="100" Height="50" Stroke="Black" StrokeThickness="1">
      <Rectangle.Fill>
        <RadialGradientBrush GradientStops="{StaticResource myGradientStops}" Opacity="0" />
      </Rectangle.Fill>
    </Rectangle>
    </StackPanel>
</Window>

   
    
     


RadialGradientBrush examples and Define GradientStop in Resource

image_pdfimage_print


   
  
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
    <Window.Resources>
    <GradientStopCollection x:Key="myGradientStops">
      <GradientStop Offset="0.0" Color="Blue" />
      <GradientStop Offset="0.4" Color="Black" />
      <GradientStop Offset="0.5" Color="White" />
      <GradientStop Offset="0.6" Color="Black" />
      <GradientStop Offset="0.7" Color="Blue" />
    </GradientStopCollection>
    
    </Window.Resources>
    <Rectangle Width="175" Height="90" Stroke="Black">
      <Rectangle.Fill>
        <RadialGradientBrush GradientStops="{StaticResource myGradientStops}"></RadialGradientBrush>
      </Rectangle.Fill>
    </Rectangle>

</Window>

   
    
     


RadialGradientBrush GradientOrigin

image_pdfimage_print


   
  


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      WindowTitle="StackPanel vs. DockPanel">
  <Grid Width="175" Height="150">
    <Rectangle Grid.Row="1" Grid.Column="0"  Width="100" Height="100" 
      StrokeThickness="4" Margin="4">
      <Rectangle.Fill>
        <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" 
          RadiusX="0.5" RadiusY="0.5">
          <GradientStop Color="Black" Offset="0" />
          <GradientStop Color="Gray" Offset="0.45" />
          <GradientStop Color="Black" Offset="0.85" />
        </RadialGradientBrush>
      </Rectangle.Fill>
      <Rectangle.Stroke>
        <SolidColorBrush Color="Blue"/>
      </Rectangle.Stroke>
    </Rectangle>
  </Grid>
</Page>

   
    
     


RadialGradientBrush Rectangle.Stroke

image_pdfimage_print


   
  

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      WindowTitle="StackPanel vs. DockPanel">
  <Grid Width="175" Height="150">
    <Rectangle Grid.Row="1" Grid.Column="1"  Width="100" Height="100" 
      StrokeThickness="8" Margin="4">
      <Rectangle.Fill>
        <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" 
          RadiusX="0.5" RadiusY="0.5">
          <GradientStop Color="Red" Offset="0" />
          <GradientStop Color="Green" Offset="0.45" />
          <GradientStop Color="Yellow" Offset="0.85" />
        </RadialGradientBrush>
      </Rectangle.Fill>
      <Rectangle.Stroke>
        <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" 
          RadiusX="0.5" RadiusY="0.5">
          <GradientStop Color="Black" Offset="0.95" />
          <GradientStop Color="Gray" Offset="0.95" />
        </RadialGradientBrush>
      </Rectangle.Stroke>
    </Rectangle>
  </Grid>
</Page>

   
    
     


Checked RadioButton

image_pdfimage_print


   
    

<Window x:Class="SimpleStyles.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="SimpleStyles"
  Background="#F8F8F8">
  <ScrollViewer>
    <WrapPanel>
      <HeaderedItemsControl Header="RadioButton">
        <RadioButton Margin="8">Normal</RadioButton>
        <RadioButton Margin="8" IsChecked="true">Checked</RadioButton>
        <RadioButton Margin="8">Normal</RadioButton>
      </HeaderedItemsControl>
   
    </WrapPanel>
  </ScrollViewer>
</Window>