Skip to content

DataGridExtensions + DataView #100

Answered by tom-englert
Morigun asked this question in Q&A
Discussion options

You must be logged in to vote

I think this is a good WPF approach to get dynamic columns:

        public MainWindow()
        {
            InitializeComponent();

            DataGrid.ItemsSource = new ObservableCollection<object>
            {
                CreateItem(true, "Value1"),
                CreateItem(false, "Value2"),
                CreateItem(true, "Value3"),
                CreateItem(false, "Value4")
            };

            DataGrid.Columns.Add(new DataGridCheckBoxColumn() { Binding = new Binding("Column1") });
            DataGrid.Columns.Add(new DataGridTextColumn() { Binding = new Binding("Column2") });
        }

        static object CreateItem(bool col1, string col2)
        {
            var

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@Morigun
Comment options

@Morigun
Comment options

@Morigun
Comment options

Comment options

You must be logged in to vote
2 replies
@Morigun
Comment options

@Morigun
Comment options

Answer selected by Morigun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants