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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:01:04+00:00 2026-05-29T06:01:04+00:00

I have defined a static resource: <UserControl x:Class=MyProject.MainPage xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:sys=clr-namespace:System;assembly=mscorlib mc:Ignorable=d

  • 0

I have defined a static resource:

<UserControl x:Class="MyProject.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
   xmlns:sys="clr-namespace:System;assembly=mscorlib" 
   mc:Ignorable="d" 
   Width="255" 
   Height="300">

   <UserControl.Resources>
      <sys:Double x:Key="CornerRadiusValue">5</sys:Double>
   </UserControl.Resources>
...

Later on in XAML file, I am trying to use that value when setting top left corner radius for a border:

<Border 
   Width="40"
   Height="30"
   BorderThickness="1,1,0,0" 
   BorderBrush="Red">
      <Border.CornerRadius>
         <CornerRadius TopLeft="{StaticResource CornerRadiusValue}" />
      </Border.CornerRadius>
</Border>

In design time, everything works fine and changing the value for CornerRadiusValue static resource changes the corner radius on a border. However, when I want to run this, I get an XamlParseException exception with the message:

Cannot set read-only property `System.Windows.CornerRadius.TopLeft’.

What am I doing wrong? How do I make it work? 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-05-29T06:01:05+00:00Added an answer on May 29, 2026 at 6:01 am

    MSDN:

    You can set this value in XAML, but only as part of the attribute syntax for properties that take a CornerRadius, or as initialization text of a CornerRadius object element. See XAML sections and Remarks sections of CornerRadius.

    You could try to bind the whole CornerRadius property and use a converter to get all the resources and create a CornerRadius instance from them using the constructor.

    e.g. using only one value:

    <Border Name="bd" BorderBrush="Red" BorderThickness="1">
        <Border.Resources>
            <sys:Double x:Key="CR_TopLeft">5</sys:Double>
        </Border.Resources>
        <Border.CornerRadius>
            <Binding ElementName="bd">
                <Binding.Converter>
                    <vc:CornerRadiusConverter />
                </Binding.Converter>
            </Binding>
        </Border.CornerRadius>
        <Button>!</Button>
    </Border>
    
    public class CornerRadiusConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var resourceSource = (FrameworkElement)value;
            var topLeft = (double)resourceSource.Resources["CR_TopLeft"];
            return new CornerRadius(topLeft, 0, 0, 0);
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
    

    You could propbably make this more generic by searching for the resources going up the tree and not directly targeting the object on which the resources are defined.

    (This is a Silverlight-only problem, in WPF your code works just fine, if you have a Silverlight question please avoid the WPF tag unless the problem actually exists in WPF)

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

Sidebar

Related Questions

I have a WPF usercontrol defined in xaml <UserControl x:Class=AIT.Modules.ComponentEditor.Editor.Controls.AITButton 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
I have the following route's defined: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute(
I have a class (called Employee. non static) defined in a class library. I
I have a static object defined in my logging class, along the lines of:
I have this user defined function. public partial class UserDefinedFunctions { static int i;
I have defined: [RdfSerializable] public class SomeItem { // Unique identificator of the resource
I have a static class in which one property defines a resource manager. for
I have the following routes defined: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute(name:
I have a function defined like this: public static void ShowAbout(Point location, bool stripSystemAssemblies
I have an array defined as; static double Temp_data[TABLE_SIZE]; I want to change the

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.