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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:32:46+00:00 2026-05-18T01:32:46+00:00

I have a UserControl where I’d like to have some parameters of customization radius(double)

  • 0

I have a UserControl where I’d like to have some parameters of customization “radius”(double) and “contentSource” (string[]).

My UserControl is composed of a few nested controls:

<UserControl ...>
<Grid>
    <my:Menu ...>
        <my:Button>
        </my:Button>
        <my:Button>
        </my:Button>
        <my:Button>
        </my:Button>
    </my:Menu ...>
</Grid>

I’m trying to expose the parameters with:

    public double Rad
    {
        get { return (double)GetValue(RadProperty); }
        set { SetValue(RadProperty, value); }
    }
    public static readonly DependencyProperty RadProperty =
        DependencyProperty.Register(
            "Radius",
            typeof(double),
            typeof(Menu));

    public String[] DataSource
    {
        get { return (String[])GetValue(DataSourceProperty); }
        set { SetValue(DataSourceProperty, value); }
    }
    public static readonly DependencyProperty DataSourceProperty =
        DependencyProperty.Register(
            "DataSource",
            typeof(String[]),
            typeof(Menu));

However, there seems to be two problems, the “string[]” parameter seems to be causing crashes, but mostly, I cannot set the “Radius” property at all. Is there something else I need to do to expose the parameter?

  • 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-18T01:32:47+00:00Added an answer on May 18, 2026 at 1:32 am

    How are you trying to access the values? I have copied your code into a UserControl and it seems to work fine. Have you set the DataContext for the object you are accessing these values from?

    Here is my test code, which might help:

     public partial class uc : UserControl
    {
        public uc()
        {
            InitializeComponent();
    
            this.DataContext = this;
            this.DataSource = new string[] { "hello","There" };
            this.Rad = 7;
        }
        public String[] DataSource
        {
            get { return (String[])GetValue(DataSourceProperty); }
            set { SetValue(DataSourceProperty, value); }
        }
        public static readonly DependencyProperty DataSourceProperty =
            DependencyProperty.Register(
                "DataSource",
                typeof(String[]),
                typeof(uc));
    
        public double Rad
        {
            get { return (double)GetValue(RadProperty); }
            set { SetValue(RadProperty, value); }
        }
        public static readonly DependencyProperty RadProperty =
            DependencyProperty.Register(
                "Radius",
                typeof(double),
                typeof(uc));
    
    }
    

    and the XAML:

    <UserControl x:Class="WpfApplication18.uc"
                 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">
        <Grid>
            <StackPanel>
                <TextBox Text="{Binding Path=DataSource[0]}"></TextBox>
                <TextBox Text="{Binding Path=DataSource[1]}"></TextBox>
                <TextBox Text="{Binding Path=Radius}"></TextBox>
                <TextBox Text="{Binding Path=Radius}"></TextBox>
            </StackPanel>
        </Grid>
    </UserControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one UserControl nested inside the other UserControl, something like that: <uc:MyControl1> <uc:MyControl2
I have a UserControl with a few boolean properties in it. I would like
I have a UserControl that is composed of many controls such as Buttons and
I have a UserControl with some predefined controls (groupbox,button,datagridview) on it, these controls are
I have a UserControl and it contains a Button . Now, in some Windows
I have a UserControl which I have added to my web.config <add tagPrefix=BCF src=~/controls/MyMessageBox.ascx
I have UserControl, named thisUserControl , it has two controls as shown in the
In application i have usercontrol with datagrid in it. For some columns i set
I have a usercontrol (.ascx) like this: <% if (HasAccessMediaPlans) { iPortletCounter++; %> <div
I have UserControl and I need to add (generate) some tags, basically Input tags.

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.