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

  • SEARCH
  • Home
  • 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 7638365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:09:34+00:00 2026-05-31T08:09:34+00:00

I have a Control Template for Progress Bar in my Resource Dictionary. Complete code

  • 0

I have a Control Template for Progress Bar in my Resource Dictionary. Complete code goes like this:

<ControlTemplate x:Key="KinasticPB" TargetType="ProgressBar">

  <ControlTemplate.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard>
                <Storyboard x:Name="str">
                    <QuaternionAnimation x:Name="quatanim"
                                         Storyboard.TargetProperty="(ImageBrush.Viewport)"
                                         From="0,0,36,36" 
                                         To="36,0,36,36" 
                                         Duration="0:0:5" 
                                         AutoReverse="False" 
                                         RepeatBehavior="Forever" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </ControlTemplate.Triggers>

    <!-- Custom progress bar goes here -->
    <Border Name="PART_Track" 
            Width="{TemplateBinding Width}"
            BorderBrush="{TemplateBinding BorderBrush}" 
            BorderThickness="{TemplateBinding BorderThickness}" 
            Background="{TemplateBinding Background}" 
            Height="{TemplateBinding Height}"
            CornerRadius="0"
            Padding="1.5" >

        <Grid>
            <!-- Rounded mask (stretches to fill Grid) -->
            <Border Name="mask" Background="#EEEEEE" CornerRadius="0"/>

            <!-- Any content -->

            <Rectangle Name="PART_Indicator" HorizontalAlignment="Left" Height="{TemplateBinding Height}">

                <Rectangle.OpacityMask>
                    <VisualBrush Visual="{Binding ElementName=mask}" />
                </Rectangle.OpacityMask>

                <Rectangle.Fill>

                    <ImageBrush x:Name="imgbrush"
                                ImageSource="/Kinastic.UCLibrary;component/Media/tex.png" 
                                AlignmentX="Left" 
                                Stretch="Fill" 
                                TileMode="Tile" 
                                AlignmentY="Top" 
                                ViewportUnits="Absolute" 
                                Viewport="0,0,36,36" 
                                ViewboxUnits="RelativeToBoundingBox" 
                                Viewbox="0,0,1,1"
                                >
                    </ImageBrush>

                </Rectangle.Fill>

            </Rectangle>

        </Grid>

    </Border>

</ControlTemplate>

But the animation won’t work. What I want to achieve is create an animated progress bar filling. I figured it out, that I only need to change ImageBrush’s viewport values.
Probably it is TargetProperty which is wrong.

  • 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-31T08:09:36+00:00Added an answer on May 31, 2026 at 8:09 am

    To animate a rect (the ViewPort type) use a RectAnimation rather than a QuaternionAnimation. The storyboard.TargetName property of the animation needs be set to imgbrush as well.
    Try:

    <ControlTemplate
        x:Key="KinasticPB"
        TargetType="ProgressBar">    
        <ControlTemplate.Triggers>
            <EventTrigger
                RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard>
                    <Storyboard
                        x:Name="str">
                        <RectAnimation
                            x:Name="quatanim"
                            Storyboard.TargetName="imgbrush"
                            Storyboard.TargetProperty="(ImageBrush.Viewport)"
                            From="0,0,36,36"
                            To="36,0,36,36"
                            Duration="0:0:5"
                            AutoReverse="False"
                            RepeatBehavior="Forever" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </ControlTemplate.Triggers>
    
        <!-- Custom progress bar goes here -->
        <Border
            Name="PART_Track"
            Width="{TemplateBinding Width}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Background="{TemplateBinding Background}"
            Height="{TemplateBinding Height}"
            CornerRadius="0"
            Padding="1.5">
    
            <Grid>
                <!-- Rounded mask (stretches to fill Grid) -->
                <Border
                    Name="mask"
                    Background="#EEEEEE"
                    CornerRadius="0" />
    
                <!-- Any content -->
    
                <Rectangle
                    Name="PART_Indicator"
                    HorizontalAlignment="Left"
                    Height="{TemplateBinding Height}">    
                    <Rectangle.OpacityMask>
                        <VisualBrush
                            Visual="{Binding ElementName=mask}" />
                    </Rectangle.OpacityMask>    
                    <Rectangle.Fill>    
                        <ImageBrush
                            x:Name="imgbrush"
                            ImageSource="/Kinastic.UCLibrary;component/Media/tex.png"
                            AlignmentX="Left"
                            Stretch="Fill"
                            TileMode="Tile"
                            AlignmentY="Top"
                            ViewportUnits="Absolute"
                            Viewport="0,0,36,36"
                            ViewboxUnits="RelativeToBoundingBox"
                            Viewbox="0,0,1,1">
                        </ImageBrush>    
                    </Rectangle.Fill>    
                </Rectangle>    
            </Grid>    
        </Border>    
    </ControlTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a control template for a button that looks like this: <ControlTemplate x:Key=CopyButton
If I have a Control with template like this: <Style x:Key=HomeButtonStyle TargetType={x:Type Control} >
I have the following control template: <ControlTemplate x:Key=GlassButton TargetType={x:Type Button}> <ControlTemplate.Resources> <Storyboard x:Key=Timeline1> <DoubleAnimationUsingKeyFrames
I have the following XAML/Control Template for a ListViewItem: <Window.Resources> <ControlTemplate x:Key=ItemTemplate TargetType=ListViewItem> <Border
I have a Button Style: <Style x:Key=ButtonStyle1 TargetType={x:Type Button}> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType={x:Type
I have this control template that I am writing: <Style TargetType={x:Type controls:InfoBar}> <Setter Property=Template>
I have a custom control like this: public class CustomControl1 : Control { private
I changed the control template of my ListView to look like this: <Border BorderBrush={TemplateBinding
I have seen a control template for tab control...in http://www.codeproject.com/KB/WPF/WPFOutlookNavi.aspx Is this property triggers
I have a ControlTemplate which is for the Button control, in the ControlTemplate I

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.