private static object GetContentPresenterValue(ContentPresenter contentPresent) { foreach (UIElement cellItem in contentPresent.FindVisualControls()) { Type cellItemType = cellItem.GetType(); if (cellItemType == typeof(TextBox) || cellItemType == typeof(TextBox)) { return(((TextBox)cellItem).Text); } else if (cellItemType == typeof(TextBlock) || cellItemType == typeof(TextBlock)) { return(((TextBlock)cellItem).Text); } else if (cellItemType == typeof(CheckBox) || cellItemType == typeof(CheckBox)) { return(((CheckBox)cellItem).IsChecked); } else if (cellItemType == typeof(ComboBox) || cellItemType == typeof(ComboBox)) { return(((ComboBox)cellItem).Text); } } return(null); }