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
40
Get ChildRecords from LabelPresenter inside GroupByRecord
posted

The image explains by itself. My checkbox is loaded as a LabelPresenterStyle. I want to apply IsChecked property to ChildRecords.

childrecords

Parents
No Data
Reply
  • 16495
    Verified Answer
    Offline posted

    Hello Ronald,

    You can use the AttachedToRecord property of HeaderRecord, it will return the DataRecord that this header is attached to. This way you can access the GroupByRecord and by using it's ViewableChildRecords method you can access the records  you wish, for example:

    private void CheckBox_Checked(object sender, RoutedEventArgs e)
            {
                var drp = Utilities.GetAncestorFromType((sender as CheckBox) as DependencyObject, typeof(DataRecordPresenter), true) as DataRecordPresenter;
                if (null != drp)
                {
                    var groupByRec = ((drp.DataRecord as DataRecord) as HeaderRecord).AttachedToRecord.ParentRecord as GroupByRecord;
                    if (null != groupByRec)
                    {
                        foreach (var rec in groupByRec.ViewableChildRecords)
                        {
                            var dataItem = (rec as DataRecord).DataItem as Product;
                        }
                    }
                }
            }

    I have attached a simple project, which you can use to test this approach.

    Let me know if you have any questions.

    Sincerely,
    Zhivko
    Associate Software Developer

    LabelPresenter_checkBoxes.zip
Children