public static SearchCaseListCriteriaItem CreateCaseListCriteriaItem(String item, RefreshCaseListHandler refereshList) { SearchCaseListCriteriaItem critriaItem; UIElement element; TextBox textbx = new TextBox(); textbx.Width = 125; textbx.Height = 25; textbx.TextChanged += new TextChangedEventHandler(refereshList); element = textbx; switch (item) { case "CaseID": { break; } case "Analyst": { break; } case "AnalystComment": { break; } case "FlightNumber": { break; } case "ObjectID": { break; } case "Area": { break; } case "Result": { ComboBox cmbBx = new ComboBox(); int[] vals = (int[])Enum.GetValues(typeof(WorkstationDecision)); String[] ResultList = new String[vals.Length]; int i = 0; foreach (int v in vals) { ResultList[i] = v.ToString(CultureResources.getDefaultDisplayCulture()); i++; } DataTemplate dataTemplate = new DataTemplate(typeof(String)); var binding = new Binding(); binding.Converter = new IntToDecisionConverter(); var elemFactory = new FrameworkElementFactory(typeof(ContentPresenter)); elemFactory.SetBinding(ContentPresenter.ContentProperty, binding); dataTemplate.VisualTree = elemFactory; cmbBx.ItemTemplate = dataTemplate; cmbBx.ItemsSource = ResultList; cmbBx.Height = 25; cmbBx.Width = 125; cmbBx.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; cmbBx.SelectionChanged += new SelectionChangedEventHandler(refereshList); CultureResources.getDataProvider().DataChanged += new EventHandler((object sender, EventArgs e) => { // reset the items source to refresh the display int index = cmbBx.SelectedIndex; var source = cmbBx.ItemsSource; cmbBx.ItemsSource = null; cmbBx.ItemsSource = source; cmbBx.SelectedIndex = index; }); element = cmbBx; break; } case "UpdateTime": { StackPanel panel = new StackPanel(); DatePicker datePicker = new DatePicker(); datePicker.IsTodayHighlighted = true; datePicker.SelectedDate = DateTime.Now.AddDays(-7); datePicker.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(refereshList); panel.Children.Add(datePicker); datePicker = new DatePicker(); datePicker.IsTodayHighlighted = true; datePicker.SelectedDate = DateTime.Now; datePicker.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(refereshList); // catch culture changes and refresh the date picker CultureResources.getDataProvider().DataChanged += new EventHandler((object sender, EventArgs e) => { datePicker.InvalidateVisual(); }); panel.Children.Add(datePicker); element = panel; break; } default: { element = null; break; } } if (element != null) { critriaItem = new SearchCaseListCriteriaItem(element, item); return critriaItem; } return null; }