title: How to use calculated and customized DependecyProperty in UserControl?
body: <p>I want to make an <strong>EllipticArc</strong> for a project and I created a <strong>UserControl</strong> to make it. In my code I need to calculate the <code>EndPoint</code> of the <strong>Arc</strong> according to the <code>Angle</code> , <code>Radius</code> and <code>IsLargeArc</code>. I wrote the code below but it didn't work, so nothing show up in the designer. I can't understand why this is happening. How can I solve it?</p>
  
  <p><strong>EllipticArc.cs</strong></p>
  
  <pre><code>public partial class EllipticArc: UserControl {
  public EllipticArc() {
      InitializeComponent();
  }
  
  public double Radius {
      get {
          return (int) GetValue(RadiusProperty);
      }
      set {
          SetValue(RadiusProperty, value);
      }
  }
  
  // Using a DependencyProperty as the backing store for Yaricap.  This enables animation, styling, binding, etc...
  public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(EllipticArc), new PropertyMetadata(20 d));
  
  public Point BeginPoint {
      get {
          return (Point) GetValue(BeginPointProperty);
      }
      set {
          SetValue(BeginPointProperty, value);
      }
  }
  
  // Using a DependencyProperty as the backing store for BeginPoint.  This enables animation, styling, binding, etc...
  public static readonly DependencyProperty BeginPointProperty = DependencyProperty.Register("BeginPoint", typeof(Point), typeof(EllipticArc), new PropertyMetadata(new Point(0 d, 0 d)));
  
  public double Angle {
      get {
          return (int) GetValue(AngleProperty);
      }
      set {
          SetValue(AngleProperty, value);
      }
  }
  
  // Using a DependencyProperty as the backing store for Angle.  This enables animation, styling, binding, etc...
  public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(EllipticArc), new PropertyMetadata(90 d));
  
  public bool IsLarge {
      get {
          SetValue(IsLargeProperty, Angle &gt;= 180 ? true: false);
          return (bool) GetValue(IsLargeProperty);
      }
      set {
          SetValue(IsLargeProperty, value);
      }
  }
  
  // Using a DependencyProperty as the backing store for IsLarge.  This enables animation, styling, binding, etc...
  public static readonly DependencyProperty IsLargeProperty = DependencyProperty.Register("IsLarge", typeof(bool), typeof(EllipticArc), new PropertyMetadata(false));
  
  Point CalculateEndPoint(Point beginPoint, double radius, double angle) {
  
      beginPoint.X = beginPoint.X + radius;
      beginPoint.Y = beginPoint.Y + radius;
      double xplus = Math.Sin(angle) * radius + beginPoint.X;
      double yplus = Math.Cos(angle) * radius + beginPoint.Y;
      return new Point(xplus, yplus);
  }
  public Point EndPoint {
      get {
          SetValue(EndPointProperty, CalculateEndPoint(BeginPoint, Radius, Angle));
          return (Point) GetValue(EndPointProperty);
      }
      set {
          SetValue(EndPointProperty, value);
      }
  }
  
  // Using a DependencyProperty as the backing store for EndPoint.  This enables animation, styling, binding, etc...
  public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register("EndPoint", typeof(Point), typeof(EllipticArc), new PropertyMetadata(0));
  
  public Size BarSize {
      get {
          SetValue(BarSizeProperty, new Size(Radius * 2, Radius * 2));
          return (Size) GetValue(BarSizeProperty);
      }
      set {
          SetValue(BarSizeProperty, value);
      }
  }
  
  // Using a DependencyProperty as the backing store for BarSize.  This enables animation, styling, binding, etc...
  public static readonly DependencyProperty BarSizeProperty = DependencyProperty.Register("BarSize", typeof(Size), typeof(EllipticArc), new PropertyMetadata(new Size(40, 40)));
  </code></pre>
  
  <p>}</p>
  
  <p><strong>EllipticArc.xaml</strong></p>
  
  <pre><code>&lt;UserControl x:Class="WpfApplication2.EllipticArc"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="300" d:DesignWidth="300"&gt;
  
      &lt;Grid&gt;
          &lt;Path&gt;
              &lt;Path.Data&gt;
                  &lt;PathGeometry&gt;
                      &lt;PathFigure StartPoint="{Binding BeginPoint}"&gt;
                          &lt;ArcSegment Size="{Binding BarSize}" Point="{Binding EndPoint}"
                                      SweepDirection="Clockwise" IsLargeArc="{Binding IsLarge}"
                                      RotationAngle="0"/&gt;
                      &lt;/PathFigure&gt;
                  &lt;/PathGeometry&gt;
              &lt;/Path.Data&gt;
          &lt;/Path&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>