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
190
xamgrid programatically moving columns
posted

I have a simple requirement. I assign a Obseverable collection to a xamGrid. Then I want to hide all the columns (maybe around 20 columns). Afterwards, I would like to show some columns in a given order (maybe 5-6 out of 20 columns). These shown column order is driven by xml configuration file.

I tried using the ActualPosition / Move methods from the fourm examples.. but none of them work. Can someone give me a working example. Thanks

 

 

 

 

 

 

 

 

        public void HideAllColumns()
        {
            try
            {
                if (this.grdData.FieldLayouts.Count > 0)
                {
                    foreach (Field fld in this.grdData.FieldLayouts[0].Fields)
                    {
                        fld.Visibility = Visibility.Hidden;
                    }
                }
            }
            catch (Exception ex)
            { }
        }

 

        public void SetColumnPosition(string columnName, int position)
        {
            if (this.grdData.FieldLayouts.Count > 0)
            {
                this.grdData.FieldLayouts[0].Fields[columnName].Visibility = Visibility.Visible;
                this.grdData.FieldLayouts[0].Fields[columnName].ActualPosition = new FieldPosition(position, 0, 0, 0);
            }
        }

 

When I make a call to hide and then SetColumnPosition, there seems be gaps between visible columns. I am new to wpf, but this functionality was very simple in windows grid. Please suggest what might be wrong in the above code

Parents
No Data
Reply Children
No Data