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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:46:41+00:00 2026-06-11T03:46:41+00:00

I need to create a custom shape to add on a WPF form. The

  • 0

I need to create a custom shape to add on a WPF form. The shape is just a triangle. If you are wondering, yes, I can do that with a Polygon in XAML with this:

<Polygon Fill="LightBlue" Stroke="Black" Name="Triangle">
  <Polygon.Points>
    <Point X="0" Y="0"></Point>
    <Point X="10" Y="0"></Point>
    <Point X="5" Y="-10"></Point>
  </Polygon.Points>
</Polygon>

The problem is that we need to bind a property from somewhere else that ultimately determines the size of the shape. So, I wrote a simple extension of the shape class like this:

public class Triangle:Shape
{
    private double size;

    public static readonly DependencyProperty SizeProperty = DependencyProperty.Register("Size", typeof(Double), typeof(Triangle));

    public Triangle() {            
    }

    public double Size
    {
        get { return size; }
        set { size = value; }
    }

    protected override Geometry DefiningGeometry
    {
        get {

            Point p1 = new Point(0.0d,0.0d);
            Point p2 = new Point(this.Size, 0.0d);
            Point p3 = new Point(this.Size / 2, -this.Size);

            List<PathSegment> segments = new List<PathSegment>(3);
            segments.Add(new LineSegment(p1,true));
            segments.Add(new LineSegment(p2, true));
            segments.Add(new LineSegment(p3, true));

            List<PathFigure> figures = new List<PathFigure>(1);
            PathFigure pf = new PathFigure(p1, segments, true);
            figures.Add(pf);

            Geometry g = new PathGeometry(figures, FillRule.EvenOdd, null);

            return g;
        }
    }

}

I thought that was good but the shape does not show up anywhere on the form. So, I am not sure if the DefiningGeometry method is well written. And if I cannot see anything very likely is not.
Thanks!

  • 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-11T03:46:42+00:00Added an answer on June 11, 2026 at 3:46 am

    The dependency property isn’t set up correctly. Write the Size getter/setter like this:

    public double Size
    {
        get { return (double)this.GetValue(SizeProperty); }
        set { this.SetValue(SizeProperty, value); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a custom constraint annotation which can access the value of
I am trying to create a custom shape class, that is basically a hexagon,
I am trying to create a button that has a custom shape (hexagon), but
I need to create a progressbar in arc shape. should I create a custom
How can I create a custom activity that can be chosen by the user
I'm searching for a way to create a WPF Control with custom shape which
I need to create a custom control with irregular shape, and only the visible
I need create custom dialog and put JPanel into it. Is it possible?
Need to create a custom DNS name server using C which will check against
I need to create a custom user interface using extJS/JSP which will allow me

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.