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 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

Is it possible to bind two different data to the same DataGrid column. Say
Using SilverLight, one can bind the value of a control to a property from
Given a data structure of: type Candidate = SalesRep of SalesRep | Analyst of
Possible Duplicate: Is it possible to pass parameters by reference using call_user_func_array()? I have
Is is possible to place a button inside of a ListCtrl item with wxPython?
Firstly, is it possible? Been struggling with this one for hours; I think the
I have a RoR app running rails 2.3.8 which makes use of the Rails
I have an ASP.NET GridView which displays a list of neighborhoods. I wish a
Using Spring 3 I have two forms: adding Item and invalidating Item I have
I'm looking for a Java library that would allow me to marshal XML to

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.