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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:30:44+00:00 2026-06-03T10:30:44+00:00

i am having a problem with the IDataErrorInfo, here is a sample public partial

  • 0

i am having a problem with the IDataErrorInfo, here is a sample

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.DataContext = new MainWindowViewModel();
    }
}

public class MainWindowViewModel : INotifyPropertyChanged, IDataErrorInfo
{
    public List<Person> _source1 = null;
    public List<Person> Source1
    {
        get
        {
            return _source1 ?? (_source1 = new List<Person>()
                {
                    new Person(){ Nom ="one"}
                });
        }
    }

    public List<Person> _source2 = null;
    public List<Person> Source2
    {
        get
        {
            return _source2 ?? (_source2 = new List<Person>()
                {
                    new Person(){ Nom ="two"}
                });
        }
    }


    private Person _selectedItem1;
    public Person SelectedItem1 { get { return _selectedItem1; } set { _selectedItem1 = value; RaisePropertyChanged("SelectedItem1"); } }
    private Person _selectedItem2;
    public Person SelectedItem2 { get { return _selectedItem2; } set { _selectedItem2 = value; RaisePropertyChanged("SelectedItem2"); } }

    public MainWindowViewModel()
    {
        //This is the actual way, i solve my problem
        //this.PropertyChanged += (sender, e) =>
        //    {
        //        if (e.PropertyName == "SelectedItem1")
        //        {
        //            RaisePropertyChanged("SelectedItem2");
        //        }
        //    };
    }

    public event PropertyChangedEventHandler PropertyChanged;
    public void RaisePropertyChanged(string propertyName)
    {
        if (this.PropertyChanged != null)
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }

    public string Error
    {
        get { throw new NotImplementedException(); }
    }

    public string this[string columnName]
    {
        get {

            string errors= string.Empty;

            if (columnName == "SelectedItem2")
            {
                if(this.SelectedItem1 != null && this.SelectedItem2 == null)
                    errors = "erreur";
            }

            return errors;
        }
    }
}

public class Person
{
    public string Nom { get; set; }        
}

As you can see i must inform that the SelectedItem2 is wonder since the SelectedItem1 is selected, but the redcorner does not appear. Here is the xaml code.

<Window x:Class="WpfApplication5.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<StackPanel>
    <ComboBox ItemsSource="{Binding Path=Source1}" DisplayMemberPath="Nom" SelectedItem="{Binding Path=SelectedItem1}"/>
    <ComboBox ItemsSource="{Binding Path=Source2}" DisplayMemberPath="Nom" SelectedItem="{Binding Path=SelectedItem2,ValidatesOnDataErrors=True}"/>
</StackPanel>

Is a better way to solve this problem.

  • 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-03T10:30:46+00:00Added an answer on June 3, 2026 at 10:30 am

    I think all you need to do is

    public Person SelectedItem1 
    { 
        get { return _selectedItem1; } 
        set 
        { 
           _selectedItem1 = value; 
           RaisePropertyChanged("SelectedItem1"); 
           RaisePropertyChanged("SelectedItem2"); 
        } 
    }
    

    This will cause re-evaluation of validation on SelectedItem2 when SelectedItem1 has been changed.

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

Sidebar

Related Questions

Having problem to open form in new window, script is pulled from external service.
I having problem marshaling an iterator of objects using JAXB User class: @XmlRootElement(name=User) public
I´m having problem using validation on DropDownListFor ... My Model : public class User
Having problem reading bytearray of custom objects. Any help is appreciated public class CustomObject
I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
Having problem with this bit of code qith jQuery. it should pick the values
I having problem to update the counter (integer value). this is the definitions of
i'm having problem when i want to select element using querySelector <ul class=xoxo blogroll>
i having problem in converting this C# code into VB.net. The loadLecturer seem to
I am having problem in using this font in my Application. I have imported

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.