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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:56:56+00:00 2026-06-08T05:56:56+00:00

I got a binding source not being updated when the targeted DependencyProperty of a

  • 0

I got a binding source not being updated when the targeted DependencyProperty of a custom UserControl changes.

The source is a ViewModel loaded with MEF into the DataContext of my custom UserControl.

My binding looks like this in the root XAML of MyUserControl

// MyUserControl.xaml
<MyUserControlBase x:Class="MyUserControl" MyDependencyProperty="{Binding ViewModelProperty}">

If i use the MyDependencyProperty with a FrameworkPropertyMetadata and use the callback function when the property changes i can do the following which works fine

// MyUserControlBase.cs
private static void MyDependencyProperty_Changed(DependencyObject depObj, DependencyPropertyChangedEventArgs args)
{
    var filter = (UserControl )depObj;
    var vm = (ViewModel)filter.DataContext;
    vm.ViewModelProperty= (VMPropType)args.NewValue;
}

Registration of the DependencyProperty in MyUserControlBase which inherit UserControl.

// MyUserControlBase.cs
public static readonly DependencyProperty MyDependencyPropertyProperty = DependencyProperty.Register("MyDependencyProperty",
            typeof(VMPropType),
            typeof(MyUserControlBase),
            new FrameworkPropertyMetadata(null, MyDependencyProperty_Changed));

But why can’t i get the simple two way binding to work when done in the XAML?

Output window show no binding failurs. I can see the ViewModel.ViewModelProperty getter is being called. Just not the setter once MyDependencyProperty changes.

It don’t appear to be a problem with the ordering of events. The ViewModel is created long before DependencyProperty is changed for the first time.

I’ve also looked at Setting up binding to a custom DependencyProperty inside a WPF user control
But his problem seems slightly different since i actualy inherit from my own Base class which holds the DependencyProperty.

Thank you for any help.

Edit: with link to example solution.
Solution zip here

Sorry for the scary looking link, I don’t know alot of quick fileshareing sites. If its bad post comment and I will remove it asap, but it seems ok.

  • 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-08T05:56:58+00:00Added an answer on June 8, 2026 at 5:56 am

    Answer updated / irrelevant info deleted

    After looking at the code in your sample I saw what the problem is. You have this “selector” control. In the BindDependencies method you set a binding on the MyControlBase.MyDependencyProperty. But at the same time you also bind this property to your control’s datacontext (in MyUserControl.xaml). Effectively this means that in the BindDependencies method you are overwriting the binding to your viewmodel thus it is not active after that method – you can see this yourself by breaking into before and after the SetBinding call and calling BindingOperations.GetBindingExpression(control, MyUserControlBase.MyPropertyDependencyProperty) – the bindings are different. This is why your code does not work. I guess you will have to find another way of transferring the value there 🙂

    Some additional info

    In WPF a property can be a target of only one binding. This is actually very logical – if a property is bound to two sources – which one should it use? The fact that the binding is marked as OneWayToSource does not really matter in this situation as it still counts as a binding that targets the control’s property.

    One way you can investigate and see if it works for you is the MultiBinding – it does allow to bind the control’s property to several sources by implementing your own IMultiValueConverter. You can find more info on this on MSDN in the link provided.

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

Sidebar

Related Questions

I got following CollectionViewSource definition in XAML: <UserControl.Resources> <CollectionViewSource x:Key=PersonsViewSource Source={Binding AvailablePersons}> <CollectionViewSource.SortDescriptions> <scm:SortDescription
I got following Source <UserControl.Resources> <DataTemplate x:Key=ItemTemplate> <ListBox ItemsSource={Binding Inventory} ScrollViewer.HorizontalScrollBarVisibility=Disabled ScrollViewer.VerticalScrollBarVisibility=Disabled ItemTemplate={StaticResource ItemChildTemplate}
I am binding dropdown list using Object data source. I got an error like
I've got a BindingSource with a BindingList<Foo> attached as the data source. I'd like
I've got a problem with a binding in my windows phone project. I'm binding
I've got a set of ViewModels that I'm binding to the ItemsSource property of
I've got some Columns in a DataGridView that have their Binding property set to
I've got a question regarding the Telerik RadGrid control client side binding. I want
I've got a simple WPF dialog with these two controls: <TextBox Text={Binding MyText}/> <Button
I've got the following XAML: <amq:SerialChart Grid.Column=0 Grid.Row=0 DataSource={Binding Data} CategoryValueMemberPath=Date AxisForeground=White PlotAreaBackground=Black GridStroke=DarkGray>

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.