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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:25:34+00:00 2026-06-17T04:25:34+00:00

In a WPF User Control, I am trying to mask an Image control with

  • 0

In a WPF User Control, I am trying to mask an Image control with a circle that can vary in position and size. The user left-drags to change the circle radius and right-drags to change the center point of the ellipse. I’m capturing all the needed values correctly and can properly set the radius of the mask. The problem is, that no matter what point I use for the center of the ellipse, it is drawn from the center of the Image control. Any ideas?

Below is the code that sets the mask:

private void SetMask(double _Radius)
{
        EllipseGeometry MaskGeometry = new EllipseGeometry(CenterPos, _Radius, _Radius);
        GeometryDrawing MaskDrawing = new GeometryDrawing(Brushes.Black, null, MaskGeometry);
        DrawingBrush MaskBrush = new DrawingBrush(MaskDrawing);
        MaskBrush.Stretch = Stretch.None;
        Img.OpacityMask = MaskBrush;  //Img is the Image control
}
  • 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-06-17T04:25:35+00:00Added an answer on June 17, 2026 at 4:25 am

    You also have to set the ViewboxUnits, AlignmentX, and AlignmentY properties:

    private void SetMask(double radius)
    {
        var maskGeometry = new EllipseGeometry(CenterPos, radius, radius);
        var maskDrawing = new GeometryDrawing(Brushes.Black, null, maskGeometry);
        var maskBrush = new DrawingBrush
        {
            Drawing = maskDrawing,
            Stretch = Stretch.None,
            ViewboxUnits = BrushMappingMode.Absolute,
            AlignmentX = AlignmentX.Left,
            AlignmentY = AlignmentY.Top
        };
    
        Img.OpacityMask = maskBrush;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a WPF user control that includes two group boxes and
I am trying to create a user control within a WPF application that will
Working in WPF, writing a custom user control. I am trying to change the
I'm trying to store the currently active user control in my wpf application that
I have a custom WPF user control called a TimeoutPanel that I am trying
I am trying to implement a wpf user control that binds a text box
In Blend (4), how can I run a wpf user control ? I'm trying
So I'm trying to use a WPF User Control to generate a ton of
I'm trying to create a user control in WPF to represent a Go board
I have a WPF User control that binds to a DataTable and generates CheckBox

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.