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
170
DependencyObject property setting
posted

I've been fighting with this most of the time.  I get a selection of rows from the grid and then I move to the next page ( this is a wpf app ).  My selection then populates another grid.  All that works wonderfully.  The problem is when going back.  I want my first grid to reflect the rows that I selected.  The collection fred has the correct entries.  How do I feed this back to the first grid so that it knows it has these particular rows selected?  Any guidance would be much appreciated.

 

public class DataGridExtender : Behavior<XamGrid>

    {

        private Row _firstSelection;

        public readonly static DependencyProperty SelectedDataItemsProperty

            = DependencyProperty.Register(

                "SelectedDataItems"

                , typeof(ICollection<object>)

                , typeof(DataGridExtender)

                , new PropertyMetadata(null));

 

        public ICollection<object> SelectedDataItems

        {

            get {

                return (ICollection<object>)GetValue(SelectedDataItemsProperty);

            }

            set { SetValue(SelectedDataItemsProperty, value); }

        }

 

 

public ResultFileSelectionView()  //this is a user control

        {

            InitializeComponent();

            selectedFiles = new List<CalibrationFile>();

            this.resultsList.ItemsSource = ViewModels.ResultFileSelectionViewModel.GetData();

            selectedFiles = ViewModels.ResultFileSelectionViewModel.GetFilesSelected();

 

 

 

            List<object> fred = new List<object>();

            foreach (CalibrationFile f in selectedFiles)

                fred.Add(f);

 

// I'm sure this isn't right, but I'm not sure how to get this property to percolate to the grid.

// this.resultsList is the XamDataGrid

            OnPropertyChanged(new DependencyPropertyChangedEventArgs(ViewModels.DataGridExtender.SelectedDataItemsProperty, this.resultsList, fred));

           

        }

Parents
  • 17475
    Offline posted

    Hello Kathy and thank you for posting! 

    I have been looking into your description and I will need a little clarification on the matter so I can understand your scenario better. You mentioned that the grid and the control wehre the selected items are changed are located on separate pages in a WPF application. Does the XamDataGrid control reload every time when you go back to its page? Can the selected items that are loaded on the second page be changed from that second page or they are just kept there? You can try to follow the approach suggested by Sandip in the following forum thread: http://www.infragistics.com/community/forums/t/64487.aspx  and iterate through the records to set the IsSelected property to true.

Reply Children
No Data