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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:05:04+00:00 2026-05-22T18:05:04+00:00

I have a small question but have been finding quite a few different, and

  • 0

I have a small question but have been finding quite a few different, and mostly ambiguous, answers:

I have the following user control and I am trying to bind to a public property within that control (Events). Everyone says that I have to use the data context, however, I don’t really want to do that… I just want to bind to the property from within the control’s
XAML…

The requirement is that the binding has to be 2 way so any changes in the ui will be reflected in the property (or rather the collection) it is bound to. Each Event object within that collection also implements INotifyPropertyChanged the same way as this control…

Any ideas would be greatly appreciated!

public partial class EventEditorWindow : UserControl, INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public ObservableCollection<Event> events;
    public ObservableCollection<Event> Events
    {
        get { return this.events; }
        set
        {
            if( this.events != value )
            {
                this.events = value;
                this.RaisePropertyChanged("Events");
            }
        }
    }

    private void RaisePropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            this.VerifyPropertyName(propertyName);
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    [Conditional("DEBUG")]
    [DebuggerStepThrough]
    public void VerifyPropertyName(string propertyName)
    {
        var currentObjectType = this.GetType();

        if (currentObjectType.GetProperty(propertyName) == null)
        {
            throw new ArgumentException("Property not found", propertyName);
        }
    }
}

Thanks,
Bleepzter.

  • 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-22T18:05:05+00:00Added an answer on May 22, 2026 at 6:05 pm

    In the constructor, set DataContext = this. That will effectively make your code behind your DataContext. AFAIK, you can’t completely avoid making something the DataContext.

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

Sidebar

Related Questions

I am going to be making a small user system but I have questions.
A small - little question. I have seen many application having buttons like following.
I'm writing a small webapp in Grails and I have the following question regarding
This may be a simple question, but I have been Googling for over an
This is probably a silly question but I have been thinking it over for
Quick question. I have been Googling this all morning, but it's either not there,
I have been working on a question in c++ but im stuck in a
I guess this is a quite simple (read: very simple) question, but I have
I know this question has been asked many times on here but I have
I have been pondering writing this question for quite some time. I work for

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.