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
975
Auto size/reset data records when change orientation
posted

Hello,

  I have a xamdatagrid in Horizontal Orientation with the DataRecordSizingMode set to "SizedToContentAndIndividuallySizable".  Now, when I change the size (width or height) of the record, and then change orientation to vertical, the field widths and record widths do not line up with each other.  I have attached an image that should hopefully better describe the situation I am seeing.  

How can I enable the user to individually size each record in a certain orientation, but not have the new sizings carry over when orientation is switched??

Thanks,

Chris

  • 17475
    Offline posted

    Hello Chris,

     

    I have been looking into your post and I understand what you are trying to achieve. When the DataRecordSizingMode is set to "SizedToContentAndIndividuallySizable" the individual widths of the records are saved and the user can easily change them. If the orientation of the grid is changed to vertical, this property is not changed and different widths are displayed. To prevent this from happening you could change the DataRecordSizingMode property when switching to vertical orientation:

    private void Button_Click_1(object sender, RoutedEventArgs e)

            {

                if (grid1.ViewSettings.Orientation == Orientation.Horizontal)

                {                

                    grid1.ViewSettings.Orientation = Orientation.Vertical;

                    grid1.FieldLayoutSettings.DataRecordSizingMode = DataRecordSizingMode.Default;                

                }

                else

                {

                    grid1.ViewSettings.Orientation = Orientation.Horizontal;             

                    grid1.FieldLayoutSettings.DataRecordSizingMode = DataRecordSizingMode.SizedToContentAndIndividuallySizable;

                  

                }

            }

    Please feel free to let me know if you have any other questions.