Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7058875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:09:53+00:00 2026-05-28T04:09:53+00:00

In Silverlight, I want to display progress of, for example, an uploading process as

  • 0

In Silverlight, I want to display progress of, for example, an uploading process as a sequence of incremental color fills on an image.

For example,

this is when progress is 0: enter image description here

this is when 30%:enter image description here

and 100% is a fully colored image: enter image description here

How can I control the color fill (I know this will be with the help of a trick, like a final image overlaying the original one or something) to display progress?

My task may be tricky since the image is an OpacityMask for a button in Windows Phone project.

P.S. Just to avoid confusion, as am concerned about the design side of a problem. Logic for hooking up progress with some actions is already in place. I just need to lay out the presentation of a progress.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:09:53+00:00Added an answer on May 28, 2026 at 4:09 am

    EDIT

    I made an implementation. A more thorough explanation and download of the code can be found on my blog.

    C#:

    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
    
    namespace CustomControls
    {
        [TemplatePart(Name="CLIPRECTANGLE", Type=typeof(RectangleGeometry))]
        public class ImageProgressBar : ProgressBar
        {
            public ImageProgressBar()
            {
                this.DefaultStyleKey = typeof(ImageProgressBar);
            }
    
            public ImageSource Source
            {
                get { return (ImageSource)GetValue(SourceProperty); }
                set { SetValue(SourceProperty, value); }
            }
    
            public static readonly DependencyProperty SourceProperty =
                DependencyProperty.Register("Source", typeof(ImageSource), typeof(ImageProgressBar), new PropertyMetadata(null));
    
            public Brush Fill
            {
                get { return (Brush)GetValue(FillProperty); }
                set { SetValue(FillProperty, value); }
            }
    
            public static readonly DependencyProperty FillProperty =
                DependencyProperty.Register("Fill", typeof(Brush), typeof(ImageProgressBar), new PropertyMetadata(null));
    
            private RectangleGeometry _clip;
    
            public override void OnApplyTemplate()
            {
                base.OnApplyTemplate();
                _clip = this.GetTemplateChild("CLIPRECTANGLE") as RectangleGeometry;
                this.ValueChanged += ImageProgressBar_ValueChanged;
                this.SizeChanged += ImageProgressBar_SizeChanged;
            }
    
            void ImageProgressBar_SizeChanged(object sender, SizeChangedEventArgs e)
            {
                UpdateClip();
            }
    
            void ImageProgressBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
            {
                UpdateClip();
            }
    
            private void UpdateClip()
            {
                if (_clip != null)
                {
                    _clip.Rect = new Rect(0, 0, this.ActualWidth, this.ActualHeight * ((this.Value - this.Minimum) / (this.Maximum - this.Minimum)));
                }
            }
        }
    }
    

    Template: generic.xaml

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:local="clr-namespace:CustomControls">
        <Style TargetType="local:ImageProgressBar">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="local:ImageProgressBar">
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Margin="{TemplateBinding Margin}"
                                Background="{TemplateBinding Background}"
                                Width="{TemplateBinding Width}"
                                Height="{TemplateBinding Height}">
                            <Grid>
                                <Image Source="{TemplateBinding Source}"
                                       Stretch="Fill" />
                                <Rectangle Fill="{TemplateBinding Fill}">
                                    <Rectangle.OpacityMask>
                                        <ImageBrush ImageSource="{Binding Path=Source, RelativeSource={RelativeSource TemplatedParent}}"
                                                    Stretch="Fill" />
                                    </Rectangle.OpacityMask>
                                    <Rectangle.Clip>
                                        <RectangleGeometry x:Name="CLIPRECTANGLE" />
                                    </Rectangle.Clip>
                                </Rectangle>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    
    </ResourceDictionary>
    

    How to use:

    <my:ImageProgressBar Width="100"
                            Height="100"
                            Fill="Red"
                            Source="ProgressBar.png"
                            Minimum="100"
                            Maximum="200"
                            Value="{Binding ElementName=slider1, Path=Value, Mode=TwoWay}" />
    <Slider Margin="0"
            Name="slider1"
            VerticalAlignment="Top"
            Minimum="100"
            Maximum="200"
            Value="125" />
    

    Works like a charm:

    Example

    Original Answer

    You could create a Linear gradient brush like this:

    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="Black" Offset="0"/>
        <GradientStop Color="Black" Offset="1"/>
        <GradientStop Color="Lime" Offset="1"/>
        <GradientStop Color="Lime" Offset="1"/>
    </LinearGradientBrush>
    

    And draw the shape/character/text/whatever using this brush.

    To show progress just update the Offsets of the middle two gradientstops. You can bind these to make it easier.

    To make a real progress bar: Make a Template for the ProgressBar and (multi)bind the Offsets to the Value, Minimum and Maximum of the Progressbar and calculate the offset by (Value - Minimum)/(Maximum - Minimum)

    To use a bitmap (PNG):

    <Grid HorizontalAlignment="Center"
            VerticalAlignment="Center">
        <Image Source="ProgressBar.png"
                Width="100"
                Height="100" />
        <Rectangle Fill="Lime">
            <Rectangle.OpacityMask>
                <ImageBrush ImageSource="ProgressBar.png" />
            </Rectangle.OpacityMask>
            <Rectangle.Clip>
                <RectangleGeometry Rect="0,25,100,75"/>
            </Rectangle.Clip>
        </Rectangle>
    </Grid>
    

    Replace the Rect when the progress changes. To cut off the correct amount.

    Note that the same image is used for the mask.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting out with Silverlight. I want to display a list of messages
I want to display a silverlight web page inside my java desktop application. Does
i want to display a table (like a footbal table) in silverlight in a
I want to use LoadingRowGroup event in SilverLight DataGrid to display a group summary.
Within a Silverlight 3.0 application I want to use the AssemblyFileVersion to display the
I'm looking to build a Silverlight application and want to display a Tag Cloud
I've just written a Silverlight app and want to deploy it. This app is
Say I want to display an image, with some hot links, rollover, and similar.
I have seen this post: Display GIF in a WP7 application with Silverlight But
I am new to Silverlight and want to animate a ball that is shot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.