WPF DataGrid and Hiding Columns

Looking for advice here 🙂 I find that in the WPF/Silverlight DataGrids there’s this option which is really useful;

AutoGenerateColumns=”true/false”

but I generally don’t want either true or false. What I seem to want is;

“Autogenerate all of them but I don’t want to display columns A,B,C”

and I’m not sure how I do that. I ended up deriving my own DataGrid just to try and make that work as in;

  [ContentProperty("Name")]
  public class HiddenColumn
  {
    public HiddenColumn()
    {
    }
    public string Name { get; set; }
  }
  class HideableDataGrid : DataGrid
  {
    public HideableDataGrid()
    {
      HiddenColumns = new List<HiddenColumn>();
      this.AutoGeneratingColumn += OnGeneratingColumn;
    }

    void OnGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
    {
      if (HiddenColumns != null)
      {
        e.Cancel = HiddenColumns.Exists(hc => string.Compare(e.PropertyName, hc.Name, true) == 0);
      }
    }
    public List<HiddenColumn> HiddenColumns { get; set; }
  }

and then use that as in;

 <local:HideableDataGrid
      x:Name="ordersGrid"
      Grid.Row="2"
      Style="{StaticResource myStyle}"
      AutoGenerateColumns="True"
      DataContext="{Binding ElementName=customersGrid,Path=SelectedValue.Orders}"
      ItemsSource="{Binding}"
      InitializingNewItem="OnOrdersGridRowInsert">
      <local:HideableDataGrid.HiddenColumns>
        <local:HiddenColumn>CustomerID</local:HiddenColumn>
        <local:HiddenColumn>CompanyName</local:HiddenColumn>
        <local:HiddenColumn>OrderID</local:HiddenColumn>
      </local:HideableDataGrid.HiddenColumns>
    </local:HideableDataGrid>

but this can’t be the right thing to do here? ( + the naming I’ve given the derived class is horrible ).