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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:27:41+00:00 2026-05-25T22:27:41+00:00

I am sure this will turn out to be something simple. I have the

  • 0

I am sure this will turn out to be something simple. I have the following Silverlight 4 C# code:

Rectangle r = new Rectangle();
r.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
r.SetValue(Canvas.LeftProperty, 150f);
r.SetValue(Canvas.TopProperty, 50f);
r.Width = 100;
r.Height = 100;

LayoutRoot.Children.Add(r);

For some reason, when I run my application, it is getting an error on the SetValue lines. The error I am getting is:

Uncaught Error: Unhandled Error in Silverlight Application DependencyProperty of type System.Double cannot be set on an object of type System.Single.

I tried to cast implicitly to Single, but still got the same error. Any ideas?

  • 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-25T22:27:42+00:00Added an answer on May 25, 2026 at 10:27 pm

    You’re passing in a boxed float, and the rectangle is then trying to unbox it to a double. Just pass in doubles to start with, and it should be fine:

    r.SetValue(Canvas.LeftProperty, 150d);
    r.SetValue(Canvas.TopProperty, 50d);
    

    Note that Canvas.Left and Canvas.Top are of type double, not float.

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

Sidebar

Related Questions

Im sure this will be a simple one but have a project that started
I'm sure this will be very simple for you experts. SUDZC is set up
I am fairly new to PHP and Codeigniter so im sure this will be
I'm sure this will equate down to the use of the COUNT statement but
I am not sure if this will be right place to ask the question,
ATM i cant quiet imagine how this will work. I'm sure it can be
I'm not sure why, but this condition will never evaluate True for me. I'm
I'm not sure how to approach this: I want a TreeView that will display
I seem to have some weird issue going on that I am sure will
I am not sure if this is possible, but I have a scenario where

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.