DataRecord record = dg.FieldLayouts[0].DataPresenter.Records[0] as DataRecord;
Record rec1 = record.DataPresenter.Records[0] as Record; Record rec2 = record as Record;
I try to receive RecordPresenter of one DataRecord RecordPresenter rp1 = DataRecordPresenter.FromRecord(rec1); RecordPresenter rp2 = RecordPresenter.FromRecord(rec1);
RecordPresenter rp3 = DataRecordPresenter.FromRecord(rec2); RecordPresenter rp4 = RecordPresenter.FromRecord(rec2);
REsult: rp1 = rp2 = rp3 = rp4 = null (always)
What I must to do for receiving RecordPresenter, that is not null?
Thanks for help.
In DoSomethigInGrid(), before you are accessing the presenter , update the grid layout using xamDataGrid1.UpdateLayout();
For a similar problem of mine, the presenter had a value after the grid layout was updated.
Hi, Joe
I wrote a sample.
1. if(xamDataGrid1.FieldLayouts[0].DataPresenter.Records[0] != null)
{
DataRecordPresenter drp1 =
DataRecordPresenter.FromRecord(xamDataGrid1.FieldLayouts[0].DataPresenter.Records[0])
as DataRecordPresenter;
if (drp1 != null)
drp1.Background = Brushes.Red;
}
//Result : drp1 =null
2. problem with grouping: first group by "Date" column, next grope by Id_t2; As a result "Groups for Id_t2" we have for each "Date", but not only for some "Group for Date".
Best regards,
Hi -
Even though you have posted the relevant portions of your application here, it is not possible to tell from the code when these routines are being called. At this point, I think the best thing to do is to post a simple (but complete) Visual Studio sample project that demonstrates the problem and I will be happy to take a look at it.
Joe
<igDP:XamDataGrid x:Name="xamDataGrid1"
GroupByAreaLocation="AboveDataArea"
<igDP:FieldSettings
AllowEdit="False"
ExpandableFieldRecordExpansionMode="ExpandAlways"
</igDP:XamDataGrid.FieldSettings>
<igDP:FieldLayoutSettings HighlightAlternateRecords="True" />
<igDP:FieldLayout Key="FieldLayout11">
...
</igDP:XamDataGrid.FieldLayouts>
<igDP:XamDataGrid x:Name="xamDataGrid2"
<igDP:FieldLayout Key="FieldLayout12">
<igDP:XamDataGrid x:Name="xamDataGrid3"
<igDP:FieldLayout Key="FieldLayout13">
</igDP:XamDataGrid>
(xamDataGrid2.FieldLayouts[0].DataPresenter.Records[0] as DataRecord).IsActive = true;
(xamDataGrid1.FieldLayouts[0].DataPresenter.Records[0] as DataRecord).IsSelected = true;
DoSomethigInGrid(xamDataGrid1);
DoSomethigInGrid(xamDataGrid2);
DoSomethigInGrid(xamDataGrid3);
//so in this procedure drp1 != null
//so in this procedure drp2 != null
//so in this procedure drp3 != null
// when ActiveRecords != null
xdg.FieldLayouts[0].DataPresenter.Records.Count > 0 &&
DataRecordPresenter drp =
DataRecordPresenter.FromRecord(xdg.ActiveRecord) as DataRecordPresenter;
//so in this procedure drp=null
DataRecordPresenter drp= DataRecordPresenter.FromRecord(this.xamDataGrid1.ViewableRecords[0]) as DataRecordPresenter; DataRecordPresenter drp = DataRecordPresenter.FromRecord(this.xamDataGrid1.Records[0]) as DataRecordPresenter;
DataRecordPresenter drp= DataRecordPresenter.FromRecord(this.xamDataGrid1.ViewableRecords[0]) as DataRecordPresenter;
DataRecordPresenter drp = DataRecordPresenter.FromRecord(this.xamDataGrid1.Records[0]) as DataRecordPresenter;