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
1025
Unable to get RecordPresenter from Record
posted

I have the following code that always seems to return null. What am I doing wrong here? I am trying to attach a ContextMenu to the Record. Unless someone has an idea how I can show a ContextMenu that queues off of the selected Record. ie. Delete this selected row.

void theDataGrid_InitializeRecord(object sender, InitializeRecordEventArgs e)

{

if (e.Record != null)

{

DataRecordPresenter drp = DataRecordPresenter.FromRecord(e.Record) as DataRecordPresenter;

}

}

 

Thanks,

Rod

Parents
No Data
Reply
  • 8576
    Offline posted
    Hi Rod -
     
    This is a timing issue - when InitializeRecord is called we are creating the DataRecord 'wrappers' for each of the items in the data source, but we have not yet created the associated DataRecordPresenters.  You would need to either wait until the after DataRecordPresenter has been created (i.e., after the DataRecord has been displayed) or do this asynchronously like so:
     

    void theDataGrid_InitializeRecord(object sender, InitializeRecordEventArgs e)

    {

    if (e.Record != null)

    this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new RecordMethod(this.GetRecordPresenterForRecord), e.Record);

    }

    delegate void RecordMethod(Record rcd);

    private void GetRecordPresenterForRecord(Record rcd)

    {

    DataRecordPresenter drp = DataRecordPresenter.FromRecord(rcd) as DataRecordPresenter;

    }

    Joe
     
     
     
    "rodyager" wrote in message news:23817@forums.infragistics.com...

    I have the following code that always seems to return null. What am I doing wrong here? I am trying to attach a ContextMenu to the Record. Unless someone has an idea how I can show a ContextMenu that queues off of the selected Record. ie. Delete this selected row.

    void theDataGrid_InitializeRecord(object sender, InitializeRecordEventArgs e)

    {

    if (e.Record != null)

    {

    DataRecordPresenter drp = DataRecordPresenter.FromRecord(e.Record) as DataRecordPresenter;

    }

    }

     

    Thanks,

    Rod



    http://forums.infragistics.com/forums/p/5266/23817.aspx#23817

Children
No Data