Question : Limiting a DataGrid in WPF with ComboBoxes...

What is the best way to limit a datagrid in WPF?  Right now I am trying to use comboBoxs I am open to other ideas.

I have a DataGrid that populates from a dataset.
the dataset has 7 columns 5 of them need to be limited by selecting items in the comboboxes

I've tried this, but it doesn't seem to work.
Throws the error "'System.Windows.Data.BindingListCollectionView' view does not support filtering."

Where am I going wrong?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
 
         
         
 
 
 
        private void FilterIconInfoRow(object sender, FilterEventArgs e) 
        { 
            IconUtilityDataSet.IconInfoRow row = e.Item as IconUtilityDataSet.IconInfoRow; 
            if (row == null) 
                e.Accepted = false; 
            else 
            { 
                // Blah... 
            } 
        }

Answer : Limiting a DataGrid in WPF with ComboBoxes...

Not quite sure i understander task right, but try something like in attached code snipet if you know witch columns you want to remove.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
XAML:

    
        
            
                
                
            
        
        
            
            
        
    


CS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// 
    /// Interaction logic for Window1.xaml
    /// 
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch(((ComboBoxItem)comboBox1.SelectedValue).Content.ToString())
            {
                case "1":
                    dataGrid1.Columns[0].Visibility = Visibility.Collapsed;
                    break;
                case "1 2":
                    dataGrid1.Columns[0].Visibility = Visibility.Visible;
                    dataGrid1.Columns[0].Visibility = Visibility.Visible;
                    break;
            }
        }
    }
}
Random Solutions  
 
programming4us programming4us