private void ClearClicked(object sender, RoutedEventArgs e) { try { var mainGrid = AutoFilterHelper.CurrentGrid; if (mainGrid == null) { return; } _isLoading = true; var distictictValues = AutoFilterHelper.CurrentDistictValues; foreach (var distictictValue in distictictValues) { if (distictictValue.IsChecked) { distictictValue.IsChecked = false; } } AutoFilterHelper.CurrentDistictValues = distictictValues; AutoFilterHelper.RemoveAllFilter(CurrentGrid, CurrentColumn); AutoFilterHelper.CurrentListBox.Items.Refresh(); AutoFilterHelper.RemoveAllFilter(mainGrid, AutoFilterHelper.CurrentColumName); var sp = FindControls.FindParent <StackPanel>(AutoFilterHelper.CurrentListBox); var popup = sp.Parent as Popup; if (popup != null) { popup.Tag = "False"; } } finally { _isLoading = false; } }
private void FoldersTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e) { TreeViewItem item = FindControls.FindParent <TreeViewItem>(e.OriginalSource as DependencyObject); if (item == null) { return; } TreeViewItem parentItem = item.Parent as TreeViewItem; if (parentItem == null) { parentItem = (TreeViewItem)((TreeView)item.Parent).Items[0]; } Folder folder = item.Tag as Folder; Folder parentFolder = parentItem.Tag as Folder; SiteSetting siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(folder.SiteSettingID); object obj = item.Tag; IConnectorMainView connectorExplorer = FindControls.FindParent <OutlookConnectorExplorer>(this); object inspector = connectorExplorer != null ? connectorExplorer.Inspector : null; ContextMenuManager.Instance.FillContextMenuItems(FoldersTreeView.ContextMenu, siteSetting, folder, inspector, parentFolder); }
private void PopLostFocus(object sender, RoutedEventArgs e) { var stackPanel = sender as StackPanel == null?FindControls.FindParent <StackPanel>((FrameworkElement)sender) : (StackPanel)sender; if (stackPanel == null) { return; } var popup = (Popup)stackPanel.Parent; if (popup == null) { return; } if (popup.IsMouseOver) { return; } var currentFocueedElement = FocusManager.GetFocusedElement(popup); if (currentFocueedElement == null) { popup.IsOpen = false; } }
private void Checked(object sender, RoutedEventArgs e) { if (_isLoading) { return; } try { var checkbox = (CheckBox)sender; var value = Convert.ToString(checkbox.Content); if (Convert.ToString(checkbox.Tag) != "(Select All)") { AutoFilterHelper.ApplyFilters(CurrentGrid, CurrentColumn, value); } else { _isLoading = true; var distictictValues = AutoFilterHelper.CurrentDistictValues; foreach (var distictictValue in distictictValues) { if (distictictValue.Name != "(Select All)" && distictictValue.IsSelectAll != "(Select All)") { distictictValue.IsChecked = true; } } AutoFilterHelper.CurrentDistictValues = distictictValues; AutoFilterHelper.RemoveAllFilter(CurrentGrid, CurrentColumn); foreach (var c in distictictValues) { c.IsChecked = true; } var sp1 = FindControls.FindParent <StackPanel>(AutoFilterHelper.CurrentListBox); var popup1 = sp1.Parent as Popup; if (popup1 != null) { var clearButton = FindControls.FindChild <Button>(popup1.Child, "btnClear"); if (clearButton != null) { clearButton.IsEnabled = true; } } AutoFilterHelper.CurrentListBox.UpdateLayout(); AutoFilterHelper.CurrentListBox.Items.Refresh(); return; } var sp = FindControls.FindParent <StackPanel>(AutoFilterHelper.CurrentListBox); var popup = sp.Parent as Popup; if (popup != null) { popup.Tag = "True"; } AutoFilterHelper.CurrentListBox.UpdateLayout(); AutoFilterHelper.CurrentListBox.Items.Refresh(); } finally { _isLoading = false; } }
async void permission() { bool loadWindow = false; var borders = FindControls.FindVisualChildren <Border>(this); if (borders.Count() == 0) { await Task.Delay(0500); } borders = FindControls.FindVisualChildren <Border>(this); if (!SectionData.isAdminPermision()) { foreach (Border border in FindControls.FindVisualChildren <Border>(this)) { if (border.Tag != null) { if (MainWindow.groupObject.HasPermission(border.Tag.ToString(), MainWindow.groupObjects)) { border.Visibility = Visibility.Visible; if (!loadWindow) { Button button = FindControls.FindVisualChildren <Button>(this).Where(x => x.Name == "btn_" + border.Tag).FirstOrDefault(); button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); loadWindow = true; } } else { border.Visibility = Visibility.Collapsed; } } if (borders.Count() != 0) { stopPermission = true; } } } else { foreach (Border border in FindControls.FindVisualChildren <Border>(this)) { if (border.Tag != null) { border.Visibility = Visibility.Visible; } } Btn_locations_Click(btn_locations, null); if (borders.Count() != 0) { stopPermission = true; } } }
public void ClearFilter(string columnName) { AutoFilterHelper.RemoveAllFilter(this, columnName); Microsoft.Windows.Controls.Primitives.DataGridColumnHeader header = FindControls.GetColumnHeaderFromColumn(Columns[GetColumnIndex(Columns, columnName)]); if (header != null) { var popUp = FindControls.FindChild <Popup>(header, "popupDrag"); if (popUp != null) { popUp.Tag = "False"; } } }
private void AutoFilterGlphLoaded(object sender, RoutedEventArgs e) { var column = FindControls.FindParent <Microsoft.Windows.Controls.Primitives.DataGridColumnHeader>((ContentControl)sender); if (column == null) { return; } var extendedColumn = column.Column as IExtendedColumn; if (extendedColumn != null && !extendedColumn.AllowAutoFilter) { ((ContentControl)(sender)).Visibility = Visibility.Collapsed; } }
/// <summary> /// Fakes a click on each history column list item so that their checkboxes are properly initialised. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Activated(object sender, System.EventArgs e) { List <DependencyObject> listBoxes = new List <DependencyObject>(); FindControls.GetChildren(this, typeof(ListBox), ref listBoxes); foreach (ListBox l in listBoxes) { if ((l.Items.Count > 0) && (l.Items[0].GetType().ToString().StartsWith(this.GetType().Namespace.Replace("View", "UserControls") + ".SelectionItem"))) { ForceIsSelectedUpdate(l); } } }
void clearValidate() { try { foreach (var control in requiredControlList) { System.Windows.Shapes.Path path = FindControls.FindVisualChildren <System.Windows.Shapes.Path>(this).Where(x => x.Name == "p_error_" + control) .FirstOrDefault(); if (path != null) { HelpClass.clearValidate(path); } } } catch { } }
private void Window_Loaded(object sender, RoutedEventArgs e) { _comboBoxes = FindControls.FindLogicalChildren <ComboBox>(this.GridMain).ToArray(); //--------------------------------------------------------------------- // FIXED: KI15 (User Interface Style) // Create // // Create an array of all the menu items in the window. _menuItems = FindControls.FindLogicalChildren <MenuItem>(this.MenuBar).ToArray(); // Set the last style to be the default style (already loaded). lastStyle = Settings.Default.InterfaceStyle; // Check the menu item for the default style. CheckMenuItem(lastStyle, true); }
private void LibraryContentDataGridView_ContextMenuOpening(object sender, ContextMenuEventArgs e) { ListView grid = sender as ListView; if (grid == null) { return; } DataRowView rowView = grid.SelectedItem as DataRowView; SiteSetting siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(this.SelectedFolder.SiteSettingID); object obj = rowView != null ? ((OC_Datarow)rowView.Row).Tag : this.SelectedFolder; IConnectorMainView connectorExplorer = FindControls.FindParent <OutlookConnectorExplorer>(this); object inspector = connectorExplorer != null ? connectorExplorer.Inspector : null; ContextMenuManager.Instance.FillContextMenuItems(LibraryContentDataListView.ContextMenu, siteSetting, obj, inspector, SelectedFolder); }
bool validate() { bool isValid = true; try { foreach (var control in requiredControlList) { TextBox textBox = FindControls.FindVisualChildren <TextBox>(this).Where(x => x.Name == "tb_" + control) .FirstOrDefault(); System.Windows.Shapes.Path path = FindControls.FindVisualChildren <System.Windows.Shapes.Path>(this).Where(x => x.Name == "p_error_" + control) .FirstOrDefault(); Border border = FindControls.FindVisualChildren <Border>(this).Where(x => x.Name == "brd_" + control) .FirstOrDefault(); if (textBox != null && path != null) { if (!HelpClass.validateEmpty(textBox.Text, path)) { isValid = false; } } } foreach (var control in requiredControlList) { ComboBox comboBox = FindControls.FindVisualChildren <ComboBox>(this).Where(x => x.Name == "cb_" + control) .FirstOrDefault(); System.Windows.Shapes.Path path = FindControls.FindVisualChildren <System.Windows.Shapes.Path>(this).Where(x => x.Name == "p_error_" + control) .FirstOrDefault(); Border border = FindControls.FindVisualChildren <Border>(this).Where(x => x.Name == "brd_" + control) .FirstOrDefault(); if (comboBox != null && path != null) { if (!HelpClass.validateEmpty(comboBox.Text, path)) { isValid = false; } } } } catch { } return(isValid); }
void ColorIconRefreash(string str) { foreach (Path path in FindControls.FindVisualChildren <Path>(this)) { if (path.Tag != null) { foreach (var item in menuList) { if (item == path.Tag.ToString()) { if (item == str) { path.Fill = Application.Current.Resources["MainColor"] as SolidColorBrush; } else { path.Fill = Application.Current.Resources["LightGrey"] as SolidColorBrush; } } } } } }
void openVisible(string str) { foreach (Rectangle rectangle in FindControls.FindVisualChildren <Rectangle>(this)) { if (rectangle.Tag != null) { foreach (var item in menuList) { if (item == rectangle.Tag.ToString()) { if (item == str) { rectangle.Visibility = Visibility.Visible; } else { rectangle.Visibility = Visibility.Collapsed; } } } } } }
void colorButtonRefreash(string str) { foreach (Button button in FindControls.FindVisualChildren <Button>(this)) { if (button.Tag != null) { foreach (var item in menuList) { if (item == button.Tag.ToString()) { if (item == str) { button.Background = Application.Current.Resources["MainColor"] as SolidColorBrush; } else { button.Background = Application.Current.Resources["SecondColor"] as SolidColorBrush; } } } } } }
void colorTextRefreash(string str) { foreach (TextBlock textBlock in FindControls.FindVisualChildren <TextBlock>(this)) { if (textBlock.Tag != null) { foreach (var item in menuList) { if (item == textBlock.Tag.ToString()) { if (item == str) { textBlock.Foreground = Application.Current.Resources["MainColor"] as SolidColorBrush; } else { textBlock.Foreground = Application.Current.Resources["LightGrey"] as SolidColorBrush; } } } } } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { UIElement currentStackPanel = null; object value = null; StackPanel stackPanel = null; DataTable dt = null; DataGridColumnHeader currentColumn = null; ExtendedDataGrid grid; try { if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue) { return(""); } currentColumn = (DataGridColumnHeader)values[0]; grid = FindControls.FindParent <ExtendedDataGrid>(currentColumn); if (grid == null) { return(""); } dt = ((DataTable)values[1]); if (currentColumn.Column == null) { return(""); } string computation = parameter.ToString(); stackPanel = FindControls.FindChild <System.Windows.Controls.StackPanel>(currentColumn, null); var currentColumnName = currentColumn.Column.SortMemberPath; if (currentColumnName == null) { return(""); } switch (computation) { case "Count": value = dt.Rows[ExtendedDataGrid.Count][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Count]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummaryCountFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummaryCountFormat, CultureInfo.InvariantCulture))); case "Sum": value = dt.Rows[ExtendedDataGrid.Sum][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Sum]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummarySumFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummarySumFormat, CultureInfo.InvariantCulture))); case "Average": value = dt.Rows[ExtendedDataGrid.Average][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Average]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummaryAverageFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummaryAverageFormat, CultureInfo.InvariantCulture))); case "Min": value = dt.Rows[ExtendedDataGrid.Min][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Min]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummaryMinFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummaryMinFormat, CultureInfo.InvariantCulture))); case "Max": value = dt.Rows[ExtendedDataGrid.Max][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Max]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummaryMaxFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummaryMaxFormat, CultureInfo.InvariantCulture))); case "Smallest": value = dt.Rows[ExtendedDataGrid.Smallest][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Smallest]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummarySmallestFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummarySmallestFormat, CultureInfo.InvariantCulture))); case "Largest": value = dt.Rows[ExtendedDataGrid.Largest][currentColumnName]; currentStackPanel = stackPanel == null ? null : stackPanel.Children[ExtendedDataGrid.Largest]; return(value == DBNull.Value ? string.Empty : (string.IsNullOrEmpty(grid.RowSummaryLargestFormat) ? value : System.Convert.ToDecimal(value).ToString(grid.RowSummaryLargestFormat, CultureInfo.InvariantCulture))); } return(""); } catch (Exception) { return(""); } finally { if (currentStackPanel != null) { currentStackPanel.Visibility = string.IsNullOrEmpty(System.Convert.ToString(value)) ? Visibility.Collapsed : Visibility.Visible; } //Adjust height of the summary row //get the actual height of one text box if (stackPanel != null) { var heightOfSingleElement = ((TextBlock)((System.Windows.Controls.StackPanel)(stackPanel.Children[ExtendedDataGrid.Sum])).Children[0]).ActualHeight; var countOfRowSummaries = new List <int>(); foreach (DataColumn col in dt.Columns) { int count = 0; foreach (DataRow row in dt.Rows) { if (!string.IsNullOrEmpty(System.Convert.ToString(row[col.ColumnName]))) { count++; } } countOfRowSummaries.Add(count); } int maximumCount = countOfRowSummaries.Max(); var summariesGrid = FindControls.FindParent <DataGrid>(currentColumn); if (summariesGrid != null) { if (maximumCount > 0) { summariesGrid.Height = maximumCount * heightOfSingleElement + 5; } else { summariesGrid.Height = 0; } } } } }
private void AutoFilterMouseDown(object sender, MouseButtonEventArgs e) { try { e.Handled = true; if (e.ChangedButton == MouseButton.Right) { return; } var column = FindControls.FindParent <Microsoft.Windows.Controls.Primitives.DataGridColumnHeader>((ContentControl)sender); var extendedColumn = column.Column as IExtendedColumn; if (extendedColumn != null) { if (!extendedColumn.AllowAutoFilter) { return; } } var popup = FindControls.FindChild <Popup>(column, "popupDrag"); if (popup == null) { return; } popup.IsOpen = true; //Change the position of popup with the mouse var popupSize = new Size(popup.ActualWidth, popup.ActualHeight); var position = new Point { X = column.ActualWidth - 19, Y = column.ActualHeight }; popup.PlacementRectangle = new Rect(position, popupSize); var listbox = FindControls.FindChild <ListBox>(popup.Child, "autoFilterList"); listbox.Focus(); listbox.LostFocus += PopLostFocus; var clearButton = FindControls.FindChild <Button>(popup.Child, "btnClear"); //Get the data from var mainGrid = FindControls.FindParent <ExtendedDataGrid>(popup); if (mainGrid != null) { mainGrid.CommitEdit(); mainGrid.CommitEdit(); AutoFilterHelper.CurrentListBox = listbox; AutoFilterHelper.CurrentGrid = mainGrid; CurrentColumn = column.Column.SortMemberPath; CurrentGrid = mainGrid; if (AutoFilterHelper.CurrentColumName == CurrentColumn) { List <CheckedListItem> previousValues = AutoFilterHelper.CurrentDistictValues; var currentValues = AutoFilterHelper.GetDistictValues(CurrentGrid, CurrentColumn); foreach (var checkedListItem in currentValues) { if (previousValues.Count(c => c.Name == checkedListItem.Name && c.IsSelectAll != "(Select All)") == 0 && checkedListItem.IsSelectAll != "(Select All)") { previousValues.Add(new CheckedListItem { Name = checkedListItem.Name, IsChecked = previousValues[0].IsChecked }); } } if (clearButton != null) { clearButton.IsEnabled = AutoFilterHelper.CurrentDistictValues.Count(c => c.IsChecked) > 0; clearButton.UpdateLayout(); } AutoFilterHelper.CurrentDistictValues = previousValues; AutoFilterHelper.CurrentDistictValues[0].IsSelectAll = "(Select All)"; listbox.ItemsSource = AutoFilterHelper.CurrentDistictValues; listbox.UpdateLayout(); listbox.Items.Refresh(); return; } AutoFilterHelper.CurrentColumName = CurrentColumn; var distict = AutoFilterHelper.GetDistictValues(CurrentGrid, CurrentColumn); if (distict.Count(c => !c.IsChecked) == distict.Count) { if (Convert.ToString(popup.Tag) == "True") { _isLoading = true; foreach (var checkedListItem in distict) { checkedListItem.IsChecked = true; } } } distict[0].IsSelectAll = "(Select All)"; listbox.ItemsSource = distict; if (clearButton != null) { clearButton.IsEnabled = AutoFilterHelper.CurrentDistictValues.Count(c => c.IsChecked) > 0; clearButton.Foreground = new SolidColorBrush(Colors.Black); clearButton.UpdateLayout(); } } } finally { _isLoading = false; } }
private void UnChecked(object sender, RoutedEventArgs e) { if (_isLoading) { return; } try { _isLoading = true; var checkbox = (CheckBox)sender; var listBox = FindControls.FindParent <ListBox>(checkbox); AutoFilterHelper.CurrentListBox = listBox; var popup = (Popup)((StackPanel)(listBox.Parent)).Parent; var grid = FindControls.FindParent <ExtendedDataGrid>(popup); CurrentGrid = AutoFilterHelper.CurrentGrid = grid; var value = Convert.ToString(checkbox.Content); if (Convert.ToString(checkbox.Tag) != "(Select All)") { var distictValues = AutoFilterHelper.CurrentListBox.ItemsSource as List <CheckedListItem>; if (distictValues != null) { var countOfFiltersSelected = distictValues.Count(c => c.IsChecked && c.Name != "(Select All)" && c.IsSelectAll != "(Select All)"); if (countOfFiltersSelected == distictValues.Count - 1) { _isLoading = true; distictValues[0].IsChecked = false; AutoFilterHelper.CurrentListBox.UpdateLayout(); AutoFilterHelper.CurrentListBox.Items.Refresh(); } bool isFilterApplicable = !string.IsNullOrEmpty(((DataView)CurrentGrid.ItemsSource).RowFilter) && ((DataView)CurrentGrid.ItemsSource).RowFilter.Contains(CurrentColumn + " IN "); if (!isFilterApplicable) { if (string.IsNullOrEmpty(((DataView)CurrentGrid.ItemsSource).RowFilter)) { var actualValues = ((DataView)CurrentGrid.ItemsSource).Table.Rows.Cast <DataRow>().Select(row => Convert.ToString(row[CurrentColumn])).Where(val => val != value).ToList(); AutoFilterHelper.ApplyFilters(CurrentGrid, CurrentColumn, actualValues); var distictictValues = AutoFilterHelper.CurrentDistictValues; distictictValues[0].IsChecked = false; AutoFilterHelper.CurrentDistictValues = distictictValues; AutoFilterHelper.CurrentListBox.Items.Refresh(); popup.Tag = distictictValues.Count(c => c.IsChecked) == 0 ? "False" : "True"; CurrentGrid.Items.Refresh(); CurrentGrid.UpdateLayout(); return; } else { AutoFilterHelper.CurrentDistictValues[0].IsChecked = countOfFiltersSelected == distictValues.Count - 1; AutoFilterHelper.CurrentListBox.Items.Refresh(); AutoFilterHelper.CurrentListBox.UpdateLayout(); popup.Tag = AutoFilterHelper.CurrentDistictValues.Count(c => c.IsChecked) == 0 ? "False" : "True"; CurrentGrid.Items.Refresh(); CurrentGrid.UpdateLayout(); } } else { AutoFilterHelper.RemoveFilters(CurrentGrid, CurrentColumn, value); var distictictValues = AutoFilterHelper.CurrentDistictValues; popup.Tag = distictictValues.Count(c => c.IsChecked) == 0 ? "False" : "True"; } } } else { _isLoading = true; var distictictValues = AutoFilterHelper.CurrentDistictValues; distictictValues[0].IsChecked = false; foreach (var distictictValue in distictictValues) { if (distictictValue.Name != "(Select All)" && distictictValue.IsSelectAll != "(Select All)") { distictictValue.IsChecked = false; } } AutoFilterHelper.CurrentDistictValues = distictictValues; AutoFilterHelper.RemoveAllFilter(CurrentGrid, CurrentColumn); AutoFilterHelper.CurrentListBox.Items.Refresh(); var countOfFiltersSelected = distictictValues.Count(c => c.IsChecked && c.Name != "(Select All)"); popup.Tag = countOfFiltersSelected == 0?"False":"True"; } AutoFilterHelper.CurrentGrid.Items.Refresh(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { _isLoading = false; } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { Button clearButton = null; bool value = false; var header = values[0] as DataGridColumnHeader; try { if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue) { return(false); } var dt = values[1] as DataTable; if (header == null || dt == null) { return(false); } if (header.Column == null) { return(false); } var currentColumnName = RowSummariesHelper.CurrentColumn; if (currentColumnName == null) { return(false); } if (dt.Columns.Contains(currentColumnName)) { foreach (DataRow row in dt.Rows) { if (!string.IsNullOrEmpty(System.Convert.ToString(row[currentColumnName]))) { var dockPanel = FindControls.FindChild <DockPanel>(header, null); if (dockPanel != null) { clearButton = ((StackPanel) (((Popup)(dockPanel.Children[1])).Child)).Children[ 0] as Button; if (clearButton != null) { value = true; clearButton.IsEnabled = true; } } } } } return(false); } finally { if (value) { } else { if (clearButton != null) { clearButton.IsEnabled = false; } else { var dockPanel = FindControls.FindChild <DockPanel>(header, null); if (dockPanel != null) { clearButton = ((StackPanel) (((Popup)(dockPanel.Children[1])).Child)).Children[ 0] as Button; if (clearButton != null) { clearButton.IsEnabled = false; } } } } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { _comboBoxes = FindControls.FindLogicalChildren <ComboBox>(this.GridMain).ToArray(); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { UIElement currentStackPanel = null; object value = null; try { if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue) { return(""); } var currentCoulumn = (ExtendedGrid.Microsoft.Windows.Controls.Primitives.DataGridColumnHeader)values[0]; //string currentColumnName = RowSummariesHelper.CurrentColumn; //if (currentColumnName == null) return ""; var dt = ((DataTable)values[1]); if (currentCoulumn.Column == null) { return(""); } string computation = parameter.ToString(); //if (currentCoulumn.Column.SortMemberPath != RowSummariesHelper.CurrentColumn) //{ // switch (computation) // { // case "Count": // return dt.Rows[ExtendedDataGrid.Count][currentCoulumn.Column.SortMemberPath]; // case "Sum": // return dt.Rows[ExtendedDataGrid.Sum][currentCoulumn.Column.SortMemberPath]; // case "Average": // return dt.Rows[ExtendedDataGrid.Average][currentCoulumn.Column.SortMemberPath]; // case "Min": // return dt.Rows[ExtendedDataGrid.Min][currentCoulumn.Column.SortMemberPath]; // case "Max": // return dt.Rows[ExtendedDataGrid.Max][currentCoulumn.Column.SortMemberPath]; // case "Smallest": // return dt.Rows[ExtendedDataGrid.Smallest][currentCoulumn.Column.SortMemberPath]; // case "Largest": // return dt.Rows[ExtendedDataGrid.Lasrgest][currentCoulumn.Column.SortMemberPath]; // } //} var stackpanel = FindControls.FindChild <System.Windows.Controls.StackPanel>(currentCoulumn, null); var currentColumnName = currentCoulumn.Column.SortMemberPath; switch (computation) { case "Count": value = dt.Rows[ExtendedDataGrid.Count][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Count]; return(value); case "Sum": value = dt.Rows[ExtendedDataGrid.Sum][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Sum]; return(value); case "Average": value = dt.Rows[ExtendedDataGrid.Average][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Average]; return(value); case "Min": value = dt.Rows[ExtendedDataGrid.Min][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Min]; return(value); case "Max": value = dt.Rows[ExtendedDataGrid.Max][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Max]; return(value); case "Smallest": value = dt.Rows[ExtendedDataGrid.Smallest][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Smallest]; return(value); case "Largest": value = dt.Rows[ExtendedDataGrid.Lasrgest][currentColumnName]; currentStackPanel = stackpanel == null ? null : stackpanel.Children[ExtendedDataGrid.Lasrgest]; return(value); } return(""); } catch (Exception) { return(""); } finally { if (currentStackPanel != null) { currentStackPanel.Visibility = string.IsNullOrEmpty(System.Convert.ToString(value)) ? Visibility.Collapsed : Visibility.Visible; } } }