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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:21:14+00:00 2026-05-18T12:21:14+00:00

Is it possible to bind data in the wrong direction? I want a value

  • 0

Is it possible to bind data in the “wrong” direction? I want a value in a custom control to be bound to my ViewModel. I’ve tried binding with mode “OneWayToSource” but I can’t get it to work.

Scenario (simplified):

I have a custom control (MyCustomControl) that has a dependency property that is a list of strings:

public class MyCustomControl : Control
{
    static MyCustomControl()
    {
        //Make sure the template in Themes/Generic.xaml is used.
        DefaultStyleKeyProperty.OverrideMetadata(typeof (MyCustomControl),  new FrameworkPropertyMetadata(typeof (MyCustomControl)));

        //Create/Register the dependency properties.
        CheckedItemsProperty = DependencyProperty.Register("MyStringList", typeof (List<string>),  typeof (MyCustomControl), new FrameworkPropertyMetadata(new List<string>()));
    }

    public List<string> MyStringList
    {
        get
        {
            return (List<string>)GetValue(MyCustomControl.MyStringListProperty);
        }
        set
        {
            var oldValue = (List<string>)GetValue(MyCustomControl.MyStringListProperty);
            var newValue = value;
            SetValue(MyCustomControl.MyStringListProperty, newValue);
            OnPropertyChanged(new DependencyPropertyChangedEventArgs(MyCustomControl.MyStringListProperty, oldValue, newValue));
        }
    }
    public static readonly DependencyProperty MyStringListProperty;
}

The control also contains code to manipulate this list.

I use this custom control in a UserControl that has a ViewModel. The ViewModel has a property that is also a list of strings:

public List<string> MyStringsInTheViewModel
{
    get
    {
        return _myStringsInTheViewModel;
    }
    set
    {
        if (value != _myStringsInTheViewModel)
        {
            _myStringsInTheViewModel = value;
            OnPropertyChanged("MyStringsInTheViewModel");
        }
    }
}
private List<string> _myStringsInTheViewModel;

Now I want to bind the list in my custom control (MyStringList) to the list in my ViewModel (MyStringsInTheViewModel) so that when the list is changed in the custom control it is also changed in the ViewModel. I’ve tried this but can’t get it to work…

<myns:MyCustomControl MyStringList="{Binding Path=MyStringsInTheViewModel, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}">

How can I make such a binding?

  • 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-18T12:21:14+00:00Added an answer on May 18, 2026 at 12:21 pm

    Use ObservableCollection<T> instead of List<T>. It implements INotifyCollectionChanged Interface.

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

Sidebar

Related Questions

How is it possible to make knockout data-bind work on dynamically generated elements? For
Is it possible to row bind two data frames that don't have the same
As of Silverlight 4 it is possible to data bind against a DependencyObject (instead
I'm trying to bind anchor attributes to a KnockoutJS ViewModel field. I tried something
Is it possible to bind something to a property of a control in a
Is it possible to add static text to data-bind with something like the example
I'm losing data-bind when initiating a printing process, is that possible ? Thats what
Is it possible to bind objects to gridview columns, instead of rows? I want
I'm wondering if it's possible to bind the selected value in a Twitter bootstrap
I really want to know why in the first case I can bind data

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.