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
1285
Get ComboBox instance
posted

I need to get the instance of the comboBox in the activeRecord.  I need to do this in RecordActivating event handler.  This is what I tried:

 DataRecord d = (DataRecord)e.Record;

var c =
Infragistics.Windows.Utilities.GetDescendantFromType(
(DependencyObject)d.Cells["AliasTaskKey"].DataPresenter,
typeof(XamComboEditor),false);

XamComboEditor ce = (XamComboEditor)c;

But it seems only to get the first row's ComboEditor. 

Any ideas?

Thanks

  • 69686
    Verified Answer
    posted

    Hello,

    This is because, you are searching from the XamDataGrid ( the DataPresenter property always return the XamDataGrid object) down the element tree, and the first XamComboEditor that this method will find is the XamComboEditor inside the first DataRecordPresenter. In order to make this work, you have to search from the cell down. For this, you have to get the CellValuePresenter of that cell and then call the GetDescendantFromType method passing the CVP as parent.

    However, you do not need to do this. For your convenience, the CellValuePresenter exposes an Editor property which will give you the underlying editor. You can get it using the following code snippet:

    DataRecord dr = e.Record as DataRecord;

                CellValuePresenter cvp = CellValuePresenter.FromCell(dr.Cells["AliasTaskKey"]);

                if (cvp.Editor is XamComboEditor)

                {

                    XamComboEditor editor = cvp.Editor as XamComboEditor;

                }

    Hope this helps.