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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:23:16+00:00 2026-06-13T17:23:16+00:00

I’m brand new to WPF , so I’m a bit at a loss for

  • 0

I’m brand new to WPF, so I’m a bit at a loss for how to do this. I created a very simple visual UserControl today that consists of a grid, displaying a circle with two dotted lines crossing through it. The intent is to display a circle of a given radius size. I’d like to be able to hide Height and Width, and use a custom property called RadiusSize to set the size of the control.

The Code Behind defines the RadiusSize dependency property, as such:

public static readonly DependencyProperty RadiusSizeProperty =
    DependencyProperty.Register("RadiusSize", typeof(double), typeof(Radius));

public double RadiusSize
{
    get { return (double)GetValue(RadiusSizeProperty); }
    set 
    { 
        SetValue(RadiusSizeProperty, value);
        Height = value * 2;
        Width = value * 2;
        RaisePropertyChanged("RadiusSize");
    }
}

There’s no visible change to the Height or Width property when setting up the XAML for a given Radius control and passing it a RadiusSize unfortunately. If removed, they just default to Auto. Is what I want to do possible?

  • 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-13T17:23:17+00:00Added an answer on June 13, 2026 at 5:23 pm

    Yes, it is possible. No, you are not doing it right.

    Its a bit hard to tell how you’re setting width/height on the circle, but the obvious newbie error you have in your code is that you’re doing stuff within the setter of a DependencyProperty.

    DP Bindings are not accessed through the getters/setters of your property. The binding system works behind the scenes, so if you bind to a DP on your class the getters/setters won’t be called when the bindings are updated.

    So, what are the alternatives? Many. You can add a PropertyMetadata instance to the property declaration that specifies a callback, and in that callback update other properties… or you can avoid it altogether. I’d go with the second.

    If I were going to create a UserControl with an ellipse and some other drawings in it, I’d just slap the visuals in a ViewBox and have it automatically stretch to the size of the UserControl, and forget the whole radius thing.

    But if you’re still interested in the radius, you could use an IValueConverter to do the work.

    public class RadiusConverter : IValueConverter
    {
        public object Convert(object value, /*snip*/)
        {
            // check null, type, and double.NaN here
            return (double)value * 2;
        }
        /* snip, on the round trip same as before but / 2 */
    }
    

    Then, define a Radius property in your UserControl as you have, and

    <UserControl x:Class="Derp"
        Width="{Binding Radius, Converter={StaticResource RadiusConverter}, RelativeSource={RelativeSource Self} />
    <!-- snip -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.