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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:01:28+00:00 2026-05-27T20:01:28+00:00

I have a user control with a property defined as follows: public partial class

  • 0

I have a user control with a property defined as follows:

public partial class ChartEx : UserControl
{
    private object _dataSource;

    public object DataSource
    {
        get { return _dataSource; }
        set 
        { 
            _dataSource = value; //break here
        }
    }

}

In my xaml, I’m trying to bind it to a collection (from inside data template):

<DataTemplate x:Key="tmplCounter">
    <my:ChartEx 
             DataContext="{Binding Converter={StaticResource convTest}, ConverterParameter='DataContext'}"
             DataSource="{Binding Converter={StaticResource convTest}, ConverterParameter='DataSource'}">
    </my:ChartEx>
</DataTemplate>

But in debugger I see that value that comes to DataSource setter is of type System.Windows.Data.Binding!

Value converter is never entered with parameter “DataSource”, but for “DataContext” it works perfectly. Converter is there merely for debugging purposes, without it things work same way.

How do I make Binding work for properties I defined?

  • 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-27T20:01:29+00:00Added an answer on May 27, 2026 at 8:01 pm

    OK, sorry all, I’m a moron.
    Turns out in XAML you can’t bind to “simple” properties. The prop must be a dependency property. Following works:

    public partial class ChartEx : UserControl
    {
        public event EventHandler DataSourceChanged;
    
        public object DataSource
        {
            get { return GetValue(DataSourceProperty); }
            set { SetValue(DataSourceProperty, value); }
        }
    
        public static readonly DependencyProperty DataSourceProperty =
            DependencyProperty.Register(
                "DataSource",
                typeof(object),
                typeof(ChartEx),
                new PropertyMetadata(true, OnDataSourcePropertyChanged));
    
        private static void OnDataSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChartEx source = d as ChartEx;
    
            if (source.DataSourceChanged != null)
                source.DataSourceChanged(source, new EventArgs());
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control defined as follows: <UserControl ... ...... x:name=StartPage> <ToggleButton x:Name=FullScreenToggle
I have a rather simple user control (RatingControl) that has a dependency property defined
I have a user control defined on an page as follows: <uc:MyUserControl ID=MyUserControl runat=server
I have a user control and I want to create a property of type
I have a user control from where I have to call the property of
I want to have a User Control that takes a collection of People (property
I have a user control - say ControlBase. It has SomeItems property, which is
I have an abstract user control(baseModule) that has a property that I plan on
I have created a user control (CheckedDirTree) that exposes a CheckedFolder property which in
I have an int array as a property of a Web User Control. I'd

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.