private static void OnExecuteImportFromDataTable(object sender, ExecutedRoutedEventArgs args) { SpreadsheetControl spreadsheetControl = args.Source as SpreadsheetControl; if (spreadsheetControl != null && args.Parameter != null) { spreadsheetControl.New(3); string SelectedItem = args.Parameter.ToString(); DataTable datatable; if (SelectedItem.Contains("Products")) { datatable = Data.GetDataTable("Products"); } else if (SelectedItem.Contains("Orders")) { datatable = Data.GetDataTable("Orders"); } else { datatable = Data.GetDataTable("Customers"); } spreadsheetControl.ImportFromDataTable(datatable); } }