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 663919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:32:31+00:00 2026-05-13T23:32:31+00:00

I am developing a control that is a rectangle area and will draw an

  • 0

I am developing a control that is a rectangle area and will draw an ellipse in the rectangle area when a trigger occurs. This control will be able to host other controls like, textbox’s, buttons, etc. so the circle will be drawn around them when triggered. I want the circle being drawn as an animation like you were circling the inner controls with a pen.

What is the best way to accomplish this?

I’ve been doing some research and I could use WPF animation or I could use GDI+ to accomplish the tasks. Thoughts?

  • 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-13T23:32:32+00:00Added an answer on May 13, 2026 at 11:32 pm

    WPF animation makes this extremely easy. Here is the basic technique:

    1. Create your ellipse’s visual appearance using whatever WPF functionality you like (Shapes, Paths, Geometries, Brushes, Drawings, Images, etc). This can be a simple ellipse or a fancy drawing created by your graphics designer, or anything in between.

    2. Apply an OpacityMask consisting of a wide elliptical dashed line with a single zero-length dash. Since the dash is zero-length the entire custom-styled ellipse will be invisible.

    3. Animate the length of the dash. As it gets longer parts of the ellipse will become opaque (so it will be visible) until it is all visible. By default your ellipse will animate smoothly from 0 to 1 but you can control and vary the rate the ellipse appears via the animation parameters, for example you could start slow at first then speed up.

    Overall structure of solution

    Here is the basic ControlTemplate structure:

    <ControlTemplate TargetType="MyCustomControl">
      <Grid>
    
        <Rectangle Fill="{StaticResource EllipseVisualAppearance}">
          <Rectangle.OpacityMask>
            <VisualBrush>
              <VisualBrush.Visual>
                <Ellipse
                  x:Name="opacityEllipse"
                  StrokeDashArray="0 10"
                  Stroke="Black" StrokeThickness="0.5"
                  Width="1" Height"1" />
              </VisualBrush.Visual>
            </VisualBrush>
          </Rectangle.OpacityMask>
        </Rectangle>
    
        <ContentPresenter />   <!-- This presents the actual content -->
    
      </Grid>
    </ControlTemplate>
    

    Creating your ellipse visual

    WPF is incredibly rich at expressing visuals, so the sky is the limit when it comes to what your ellipse can look like.

    Draw your ellipse exactly the way you want it to appear using any WPF drawing technique. Depending on how much “artistic style” you want from the ellipse you can do a simple (and boring) stroked ellipse or anything arbitrarily fancy, such as:

    • Stroke a path that roughly an ellipse but not closed and perhaps flared out.
    • Fill a path created by a graphic designer that starts as if a paintbrush were doing it and perhaps gets wider as you go around and ends in a blob.
    • Create a vector drawing in Expression Design (or Adobe Illustrator), convert it to a XAML Drawing.
    • Create a bitmap image (note that in general bitmaps have fidelity and performance disadvantages compared to vector drawings)
    • Draw multiple Shapes on a Canvas using Expression Blend

    Here is an ultimately simple ellipse:

    <VisualBrush x:Key="EllipseVisualAppearance">
      <VisualBrush.Visual>
        <Ellipse StrokeThickness="0.1" Stroke="Blue" />
      </VisualBrush.Visual>
    </VisualBrush>
    

    Animating your ellipse

    Again there are a huge variety of ways you can do this, depending on how you want your animation to look. For a simple 0 to 360 animation your DoubleAnimation can be as simple as:

     <DoubleAnimation
       StoryBoard.TargetName="opacityEllipse"
       StoryBoard.TargetProperty="StrokeDashArray[0]"
       From="0" To="3.1416" Duration="0:0:0.5" />
    

    The constant 3.1416 is slightly over pi, which is the circumference of a circle of diameter 1. This means that the ellipse will be fully visible just at the end of the animation duration.

    An alternative solution

    StackOverflow user Simon Fox had posted an answer containing a link to this article by Charles Petzold, but his answer disappeared a few minutes later. I guess he deleted it. The Petzold code shows a simpler way to do this using PathGeometry and ArcSegment. If all you want is a simple ellipse with no frills, modeling your code on his example is probably the way to go.

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

Sidebar

Ask A Question

Stats

  • Questions 388k
  • Answers 388k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try using the same in a console application. A console… May 15, 2026 at 12:34 am
  • Editorial Team
    Editorial Team added an answer So you are trying to send an event from html… May 15, 2026 at 12:34 am
  • Editorial Team
    Editorial Team added an answer Use a selector for the collection, then use index with… May 15, 2026 at 12:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.