Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
320
How to get the selected item
posted

I have a class like this one :
public class Car
{
      private string _color;
      public string Color
        {
            get { return _reference; }
            set
            {
                _reference = value;
            }
        }
...
...
}

 I bind the cars to the xamDataGrid like this
List<Car> myList;
myXamDataGrid.DataSource = myList;

Everything is good until I try to get the car I select into the grid. How can I get the 'Car' objet that is selected?

 

Thanks

Parents
  • 4850
    Offline posted

    The XamDataGrid exposes an ActiveRecord property, along with associated RecordActivating and RecordActivated events. The ActiveRecord property returns a Record base class which would need to be cast to a derived DataRecord. The DataRecord has a property off it called DataItem which will return the Car object, e.g.:

    DataRecord dr = this.xamDataGrid1.ActiveRecord as DataRecord;

    if ( dr != null )

    {

    Car car = dr.DataItem as Car;

    }

Reply Children
No Data