Exemple #1
0
        private static void CreateColumns(BaseListView lv)
        {
            var gridView = new GridView {
                AllowsColumnReorder = true
            };

            var properties = lv.DataType.GetProperties();

            foreach (var pi in properties)
            {
                var browsableAttribute = pi.GetCustomAttributes(true).FirstOrDefault(a => a is BrowsableAttribute) as BrowsableAttribute;
                if (browsableAttribute != null && !browsableAttribute.Browsable)
                {
                    continue;
                }

                var binding = new Binding {
                    Path = new PropertyPath(pi.Name), Mode = BindingMode.OneWay
                };
                var gridViewColumn = new GridViewColumn()
                {
                    Header = pi.Name, DisplayMemberBinding = binding
                };
                gridView.Columns.Add(gridViewColumn);
            }

            lv.View = gridView;
        }
        private static void CreateColumns(BaseListView lv)
        {
            var gridView = new GridView { AllowsColumnReorder = true };

            var properties = lv.DataType.GetProperties();
            foreach (var pi in properties)
            {
                var browsableAttribute = pi.GetCustomAttributes(true).FirstOrDefault(a => a is BrowsableAttribute) as BrowsableAttribute;
                if (browsableAttribute != null && !browsableAttribute.Browsable)
                {
                    continue;
                }

                var binding = new Binding { Path = new PropertyPath(pi.Name), Mode = BindingMode.OneWay };
                var gridViewColumn = new GridViewColumn() { Header = pi.Name, DisplayMemberBinding = binding };
                gridView.Columns.Add(gridViewColumn);
            }

            lv.View = gridView;
        }