Add TextBlock to Statusbar


   
  


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="StatusBarSimple.Window1"
    Title ="StatusBar">
  <Window.Resources>
    <Style x:Key="StatusBarSeparatorStyle" TargetType="Separator">
      <Setter Property="Background" Value="LightBlue" />
      <Setter Property="Control.Width" Value="1"/>
      <Setter Property="Control.Height" Value="20"/>
    </Style>    
  </Window.Resources>
        <StatusBar Name="sbar" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" 
                   VerticalAlignment="Bottom" Background="Beige" > 
             <StatusBarItem>
               <TextBlock>Ready</TextBlock>
             </StatusBarItem>
             <StatusBarItem>
               <Separator Style="{StaticResource StatusBarSeparatorStyle}"/>
             </StatusBarItem>
        </StatusBar>
</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 StatusBarSimple
{
    public partial class Window1 : Window
    {
        private void MakeProgressBar(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            TextBlock txtb = new TextBlock();
            txtb.Text = "Code compiled successfully.";
            sbar.Items.Add(txtb);
            Rectangle rect = new Rectangle();
            rect.Height = 20;
            rect.Width = 1;
            rect.Fill = Brushes.LightGray;
            sbar.Items.Add(rect);
        }
    }
}

   
    
     


Items that can be placed in a StatusBar


   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="StatusBarSimple.Window1"
    Title ="StatusBar">
  <Window.Resources>
    <Style x:Key="StatusBarSeparatorStyle" TargetType="Separator">
      <Setter Property="Background" Value="LightBlue" />
      <Setter Property="Control.Width" Value="1"/>
      <Setter Property="Control.Height" Value="20"/>
    </Style>    
  </Window.Resources>
        <StatusBar Name="sbar" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" 
                   VerticalAlignment="Bottom" Background="Beige" > 
             <StatusBarItem>
                <Button Content="click" Click="MakeProgressBar"/>
             </StatusBarItem>
             <StatusBarItem>
               <Separator Style="{StaticResource StatusBarSeparatorStyle}"/>
             </StatusBarItem>
        </StatusBar>
</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 StatusBarSimple
{
    public partial class Window1 : Window
    {
        private void MakeProgressBar(object sender, RoutedEventArgs e)
        {
            sbar.Items.Clear();
            TextBlock txtb = new TextBlock();
            txtb.Text = "Progress of download.";
            sbar.Items.Add(txtb);
            ProgressBar progressbar = new ProgressBar();
            progressbar.Width = 100;
            progressbar.Height = 20;
            Duration duration = new Duration(TimeSpan.FromSeconds(5));
            DoubleAnimation doubleanimation = new DoubleAnimation(100.0, duration);
            progressbar.BeginAnimation(ProgressBar.ValueProperty,doubleanimation);
            ToolTip ttprogbar = new ToolTip();
            ttprogbar.Content = "Shows the progress of a download.";
            progressbar.ToolTip = (ttprogbar);
            sbar.Items.Add(progressbar);
        }
    }
}

   
    
     


Display a Status Bar


   
    
<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="150" Width="300">
    <DockPanel LastChildFill="True">
        <StatusBar DockPanel.Dock="Bottom">
            <TextBlock  Text="Font size: " />
                <ComboBox Name="cbxFontSize" >
                    <ComboBoxItem Content="12" IsSelected="True" Margin="2" />
                    <ComboBoxItem Content="14" Margin="2" />
                    <ComboBoxItem Content="16" Margin="2" />
                </ComboBox>
                <Separator Margin="5"/>
                <RadioButton Command="EditingCommands.AlignLeft" 
                             CommandTarget="{Binding ElementName=rtbTextBox}"
                             Content="Left" IsChecked="True"/>
                <RadioButton Command="EditingCommands.AlignCenter" 
                             CommandTarget="{Binding ElementName=rtbTextBox}"                             
                             Content="Center" />
                <RadioButton Command="EditingCommands.AlignRight" 
                             CommandTarget="{Binding ElementName=rtbTextBox}"                             
                             Content="Right" />
        </StatusBar>
        <RichTextBox Name="rtbTextBox">
            <FlowDocument>
                <Paragraph FontSize="{Binding ElementName=cbxFontSize, 
                    Path=SelectedItem.Content}">
                    this is a test
                </Paragraph>
            </FlowDocument>
        </RichTextBox>
    </DockPanel>
</Window>

   
    
    
    
     


Proportional StatusBar


   
    
<Window x:Class="MenusAndToolbars.ProportionalStatusBar"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ProportionalStatusBar" Height="300" Width="300">
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
      </Grid.RowDefinitions>

      <StatusBar Grid.Row="1">
        <StatusBar.ItemsPanel>
          <ItemsPanelTemplate>
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
              </Grid.ColumnDefinitions>              
            </Grid>
          </ItemsPanelTemplate>
        </StatusBar.ItemsPanel>
        <TextBlock>Left Side</TextBlock>
        <StatusBarItem Grid.Column="1">
          <TextBlock>Right Side</TextBlock>
        </StatusBarItem>
      </StatusBar>
    </Grid>
  </Window>

   
    
    
    
     


Dock StatusBar


   
    
<Window x:Class="SimpleStyles.TestWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Test Window" Height="300" Width="300"
    Style="{StaticResource {x:Type Window}}"
    ResizeMode="CanResizeWithGrip">
  <DockPanel LastChildFill="False">
    <StatusBar DockPanel.Dock="Bottom">
      <StatusBarItem>
        Ready
      </StatusBarItem>
    </StatusBar>

  </DockPanel>
</Window>

   
    
    
    
     


Use StackPanel to arrange child objects in a single line that you can align horizontally or vertically.


   
  

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="StackPanel_layout.Window1"
    Title="StackPanel Sample">
  <Border BorderBrush="Black" Background="White" BorderThickness="2">
        <Grid VerticalAlignment="Top" HorizontalAlignment="Left">
          <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
          </Grid.ColumnDefinitions>
          <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition Height="400"/>
          </Grid.RowDefinitions>
                <TextBlock Grid.Row="2" Grid.Column="0">Change StackPanel Orientation:</TextBlock>
                <TextBlock Grid.Row="2" Grid.Column="2">Change HorizontalAlignment:</TextBlock>
                <TextBlock Grid.Row="2" Grid.Column="4">Change VerticalAlignment:</TextBlock>
                <ListBox VerticalAlignment="Top" SelectionChanged="changeOrientation" Grid.Row="2" Grid.Column="1" Width="100" Height="50" Margin="0,0,0,10">
                    <ListBoxItem>Horizontal</ListBoxItem>
                    <ListBoxItem>Vertical</ListBoxItem>
                </ListBox>
                <ListBox VerticalAlignment="Top" SelectionChanged="changeHorAlign" Grid.Row="2" Grid.Column="3" Width="100" Height="50" Margin="0,0,0,10">
                    <ListBoxItem>Left</ListBoxItem>
                    <ListBoxItem>Right</ListBoxItem>
                    <ListBoxItem>Center</ListBoxItem>
                    <ListBoxItem>Stretch</ListBoxItem>
                </ListBox>
                <ListBox VerticalAlignment="Top" SelectionChanged="changeVertAlign" Grid.Row="2" Grid.Column="5" Width="100" Height="50" Margin="0,0,0,10">
                    <ListBoxItem>Top</ListBoxItem>
                    <ListBoxItem>Bottom</ListBoxItem>
                    <ListBoxItem>Center</ListBoxItem>
                    <ListBoxItem>Stretch</ListBoxItem>
                </ListBox>
          <StackPanel Grid.ColumnSpan="6" Grid.Row="3" Name="sp1" Background="Yellow">
                <Button>One</Button>
                <Button>Two</Button>
                <Button>Three</Button>
                <Button>Four</Button>
                <Button>Five</Button>
                <Button>Six</Button>
          </StackPanel>
        </Grid>
  </Border>
</Window>

//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;

namespace StackPanel_layout
{
  public partial class Window1 : Window
  {

        public void changeOrientation(object sender, SelectionChangedEventArgs args)
        {
            ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
            if (li.Content.ToString() == "Horizontal")
            {
        sp1.Orientation = System.Windows.Controls.Orientation.Horizontal;
            }
            else if (li.Content.ToString() == "Vertical")
            {
        sp1.Orientation = System.Windows.Controls.Orientation.Vertical;
            }
        }
        public void changeHorAlign(object sender, SelectionChangedEventArgs args)
        {
            ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
            if (li.Content.ToString() == "Left")
            {
        sp1.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            }
            else if (li.Content.ToString() == "Right")
            {
        sp1.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            }
            else if (li.Content.ToString() == "Center")
            {
        sp1.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            }
            else if (li.Content.ToString() == "Stretch")
            {
        sp1.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            }
        }

        public void changeVertAlign(object sender, SelectionChangedEventArgs args)
        {
            ListBoxItem li = ((sender as ListBox).SelectedItem as ListBoxItem);
            if (li.Content.ToString() == "Top")
            {
        sp1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            }
            else if (li.Content.ToString() == "Bottom")
            {
        sp1.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            }
            else if (li.Content.ToString() == "Center")
            {
        sp1.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            }
            else if (li.Content.ToString() == "Stretch")
            {
        sp1.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            }
        }
        
    }
}

   
    
     


Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel.


   
  


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ScrollViewer_Methods.Window1"
    Title="ScrollViewer IScrollInfo Sample"
    Loaded="onLoad">
<DockPanel>
<TextBlock DockPanel.Dock="Top" FontSize="20" FontWeight="Bold" Margin="10">IScrollInfo Interface Methods</TextBlock>
<StackPanel DockPanel.Dock="Left" Width="150">
    <Button Click="spLineUp">Adjust Line Up</Button>
    <Button Click="spLineDown">Adjust Line Down</Button>
    <Button Click="spLineRight">Adjust Line Right</Button>
    <Button Click="spLineLeft">Adjust Line Left</Button>
    <Button Click="spPageUp">Adjust Page Up</Button>
    <Button Click="spPageDown">Adjust Page Down</Button>
    <Button Click="spPageRight">Adjust Page Right</Button>
    <Button Click="spPageLeft">Adjust Page Left</Button>
</StackPanel>  
<Border BorderBrush="Black" Background="White" BorderThickness="2" Width="500" Height="500">
    <ScrollViewer Name="sv1" CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
        <StackPanel Name="sp1">
            <Rectangle Width="700" Height="500" Fill="Green"/>
            <TextBlock>Rectangle 3</TextBlock>
        </StackPanel> 
    </ScrollViewer>
</Border>
</DockPanel>
</Window>

//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Text;

namespace ScrollViewer_Methods
{
    public partial class Window1 : Window
    {
        private void onLoad(object sender, System.EventArgs e)
        {
            ((IScrollInfo)sp1).CanVerticallyScroll = true;
            ((IScrollInfo)sp1).CanHorizontallyScroll = true;
            ((IScrollInfo)sp1).ScrollOwner = sv1;
        }
        private void spLineUp(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineUp();
        }
        private void spLineDown(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineDown();
        }
        private void spLineRight(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineRight();
        }
        private void spLineLeft(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).LineLeft();
        }
        private void spPageUp(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageUp();
        }
        private void spPageDown(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageDown();
        }
        private void spPageRight(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageRight();
        }
        private void spPageLeft(object sender, RoutedEventArgs e)
        {
            ((IScrollInfo)sp1).PageLeft();
        }
    }
}