Click here to Skip to main content
15,897,360 members
Articles / Desktop Programming / XAML

Custom Busyindicator style in Silverlight 4

Rate me:
Please Sign up or sign in to vote.
4.73/5 (7 votes)
5 Jul 2010CPOL2 min read 68.7K   2.6K   31  
How to create a silverlight 4 Busyindicator style with custom progressbar
  • cslighttheme.zip
    • CSTemplateApp
      • CSTemplateApp.sln
      • CSTemplateApp
        • App.xaml
        • App.xaml.cs
        • Assets
        • Bin
          • Debug
            • AppManifest.xaml
            • ar
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • bg
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ca
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • cs
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • CSTemplateApp.dll
            • CSTemplateApp.xap
            • CSTemplateAppTestPage.html
            • da
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • de
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • el
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • es
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • et
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • eu
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • fi
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • fr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • he
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • hr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • hu
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • id
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • it
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • ja
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • ko
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • lt
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • lv
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ms
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • nl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • no
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • pl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • pt
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • pt-BR
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ro
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • ru
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • sk
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sl
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sr-Cyrl-CS
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sr-Latn-CS
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • sv
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • System.ComponentModel.DataAnnotations.dll
            • System.ComponentModel.DataAnnotations.xml
            • System.Windows.Controls.Data.DataForm.Toolkit.dll
            • System.Windows.Controls.Data.DataForm.Toolkit.xml
            • System.Windows.Controls.Data.dll
            • System.Windows.Controls.Data.Input.dll
            • System.Windows.Controls.Data.Input.xml
            • System.Windows.Controls.Data.Toolkit.dll
            • System.Windows.Controls.Data.Toolkit.xml
            • System.Windows.Controls.Data.xml
            • System.Windows.Controls.DataVisualization.Toolkit.dll
            • System.Windows.Controls.DataVisualization.Toolkit.xml
            • System.Windows.Controls.dll
            • System.Windows.Controls.Input.dll
            • System.Windows.Controls.Input.Toolkit.dll
            • System.Windows.Controls.Input.Toolkit.xml
            • System.Windows.Controls.Input.xml
            • System.Windows.Controls.Layout.Toolkit.dll
            • System.Windows.Controls.Layout.Toolkit.xml
            • System.Windows.Controls.Navigation.dll
            • System.Windows.Controls.Navigation.xml
            • System.Windows.Controls.Toolkit.dll
            • System.Windows.Controls.Toolkit.Internals.dll
            • System.Windows.Controls.Toolkit.xml
            • System.Windows.Controls.xml
            • System.Windows.Data.dll
            • System.Windows.Data.xml
            • th
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • tr
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • uk
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • vi
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.resources.dll
            • zh-Hans
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
            • zh-Hant
              • System.ComponentModel.DataAnnotations.resources.dll
              • System.Windows.Controls.Data.Input.resources.dll
              • System.Windows.Controls.Data.resources.dll
              • System.Windows.Controls.Input.resources.dll
              • System.Windows.Controls.Navigation.resources.dll
              • System.Windows.Controls.resources.dll
              • System.Windows.Data.resources.dll
        • CSTemplateApp.csproj
        • CSTemplateApp.csproj.user
        • Data
        • ErrorWindow.xaml
        • ErrorWindow.xaml.cs
        • MainPage.xaml
        • MainPage.xaml.cs
        • Properties
        • Views
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation">
    
    <ResourceDictionary.MergedDictionaries>        
        <ResourceDictionary Source="Brushes.xaml"/>
        <ResourceDictionary Source="Effects.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="LayoutRootStyle" TargetType="Grid">
        <Setter Property="Background" Value="{StaticResource BrushAppBackground1}"/>
    </Style>

    <Style x:Key="BorderBackgroundStyle" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource BrushAppBackground2}"/>
    </Style>
    
    <Style x:Key="SheetStyle" TargetType="Grid">
        <Setter Property="Width" Value="800"/>
        <Setter Property="Background" Value="#F5F5F5"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Effect" Value="{StaticResource EffectSheetShaddow}"/>
        <Setter Property="Margin" Value="0 0 0 50"/>
    </Style>

    <Style x:Key="HeaderBorderStyle" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource Brush1}"/>
        <Setter Property="Margin" Value="1 0"/>
    </Style>

    <Style x:Key="HeaderBackgroundStyle" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource BrushHeaderBackground2}"/>
    </Style>
    
    <Style x:Key="HeaderTextStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource BrushHeaderText}"/>
        <Setter Property="FontSize" Value="20"/>
        <Setter Property="FontFamily" Value="Trebuchet MS"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Margin" Value="25 25 0 0"/>
    </Style>

    <Style x:Key="SubHeaderTextStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource BrushHeaderText}"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="FontFamily" Value="Trebuchet MS"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Margin" Value="25 55 0 0"/>
    </Style>
    
    <Style x:Key="PageHeaderStyle" TargetType="ContentControl">
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="{StaticResource BrushPageHeaderBackground}"/>
        <Setter Property="Height" Value="25"/>
        <Setter Property="Padding" Value="5 0 5 0"/>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid>
                        <TextBlock Text="{Binding Path=Title, ElementName=Page}" FontFamily="Trebuchet MS" 
                               Foreground="{StaticResource Brush2}" FontSize="12" FontWeight="Bold" 
                               HorizontalAlignment="Left" VerticalAlignment="Center"/>
                    </Grid>                    
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Grid>
                        <Border Background="{TemplateBinding Background}">
                            <Grid>
                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  Margin="{TemplateBinding Padding}" HorizontalAlignment="Left"/>
                                <ContentControl Content="{TemplateBinding Content}" 
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                Margin="{TemplateBinding Padding}" HorizontalAlignment="Right"/>
                            </Grid>
                            
                        </Border>
                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LinksPanelStyle" TargetType="Panel">
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Height" Value="50"/>
        <Setter Property="Effect" Value="{StaticResource EffectHeaderLinksGlow}"/>
    </Style>
    
    <Style x:Key="HeaderLinksStyle" TargetType="HyperlinkButton">
        <Setter Property="FontFamily" Value="Trebuchet MS"/>
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Foreground" Value="{StaticResource Brush1}" />
        <Setter Property="BorderThickness" Value="1 0 1 1"/>
        <Setter Property="BorderBrush" Value="{StaticResource BrushHeaderLinkBorder}"/>
        <Setter Property="Padding" Value="4 0"/>
        <Setter Property="Margin" Value="1 0"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="{StaticResource BrushHeaderLinkBackground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="HyperlinkButton">
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Duration="0:0:0"
                                                                               Storyboard.TargetName="contentPresenter"
                                                                               Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource Brush3}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>

                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                            
                            <VisualStateGroup x:Name="LinkStates">
                                <VisualState x:Name="ActiveLink">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Duration="0:0:0"
                                                                               Storyboard.TargetName="root"
                                                                               Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0 0 0 -15"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="InactiveLink"/>
                            </VisualStateGroup>

                            <vsm:VisualStateGroup x:Name="FocusStates">
                                <vsm:VisualState x:Name="Focused">
                                    <Storyboard>

                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Unfocused"/>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Border x:Name="root" CornerRadius="0 0 5 5" Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                            <Grid Cursor="{TemplateBinding Cursor}">
                                
                            
                                <TextBlock x:Name="contentPresenter" Foreground="{TemplateBinding Foreground}"
                                                    Text="{TemplateBinding Content}"
                                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                    Margin="{TemplateBinding Padding}"
                                                    Effect="{StaticResource EffectSunk}"/>
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ContentFrameStyle" TargetType="navigation:Frame" >
        <Setter Property="BorderBrush" Value="{x:Null}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="UriMapper">
            <Setter.Value>
                <uriMapper:UriMapper>
                    <uriMapper:UriMapping MappedUri="/Views/Home.xaml" Uri="" />
                    <uriMapper:UriMapping MappedUri="/Views/{pageName}.xaml" Uri="/{pageName}" />
                </uriMapper:UriMapper>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Margin" Value="1 1 1 0"/>
    </Style>

</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Bulgaria Bulgaria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions