Combobox Binding

2 posts, 0 answers
  1. Javor
    Javor avatar
    25 posts
    Member since:
    Sep 2013

    Posted 29 Aug 2018 Link to this post

    I have following code 

    when I clicked something form combobox and have error and return value to old value in that case the selected item in combobox is the last selected 

    01.public class MyClass
    03.    public int ForeignId
    04.    {
    05.        get
    06.        {
    07.            return MyObject.ForeignId;
    08.        }
    10.        set
    11.        {
    12.            int oldValue = MyObject.ForeignId;
    14.            try
    15.            {
    16.                MyObject.No = Helper.Help(value)
    17.            }
    18.            catch
    19.            {
    20.                MyObject.ForeignId = oldValue;
    21.            }
    23.            OnPropertyChanged(() => ForeignId);
    24.        }
    25.    }
    27.    public MyObject MyObject{ getset; }


    <telerik:RadComboBox ItemsSource="{Binding ItemList}" DisplayMemberPath="Name" SelectedValuePath="ForeignId"
                         SelectedValue="{Binding ForeignId, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" />


  2. Vladimir Stoyanov
    Vladimir Stoyanov avatar
    636 posts

    Posted 03 Sep 2018 Link to this post

    Hello Javor,

    Thank you for the provided code. 

    I tried to reproduce the described scenario on my side however I was not able to do so. This is why I am attaching the sample project that I used for testing. Please, check it out and see how it differs from the setup at your side. Should you need any further assistance, may I ask you to let me know what you are doing differently or share some steps which I can follow so that I can reproduce the scenario and investigate it further?

    I am looking forward to your reply.

    Vladimir Stoyanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top