本文整理汇总了C#中System.Windows.Controls.GridViewColumnHeader类的典型用法代码示例。如果您正苦于以下问题:C# GridViewColumnHeader类的具体用法?C# GridViewColumnHeader怎么用?C# GridViewColumnHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridViewColumnHeader类属于System.Windows.Controls命名空间,在下文中一共展示了GridViewColumnHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortGlyphAdorner
/// <summary>
/// Initializes a new instance of the <see cref="SortGlyphAdorner"/> class.
/// </summary>
/// <param name="columnHeader">The column header</param>
/// <param name="direction">The direction</param>
/// <param name="sortGlyph">The image glyph</param>
public SortGlyphAdorner(GridViewColumnHeader columnHeader, ListSortDirection direction, ImageSource sortGlyph)
: base(columnHeader)
{
this.columnHeader = columnHeader;
this.direction = direction;
this.sortGlyph = sortGlyph;
}
示例2: ListViewColumnHeader_Click
private void ListViewColumnHeader_Click(Object sender, RoutedEventArgs e)
{
using (listviewIssues.Items.DeferRefresh())
{
GridViewColumnHeader column = (GridViewColumnHeader)sender;
string sortBy = column.Tag.ToString();
if (listviewSortCol != null)
{
AdornerLayer.GetAdornerLayer(listviewSortCol).Remove(listviewSortAdorner);
listviewIssues.Items.SortDescriptions.Clear();
}
ListSortDirection newDir = ListSortDirection.Ascending;
if (column.Equals(listviewSortCol) && listviewSortAdorner.Direction == newDir)
{
newDir = ListSortDirection.Descending;
}
listviewSortCol = column;
listviewSortAdorner = new SortAdorner(listviewSortCol, newDir);
AdornerLayer.GetAdornerLayer(listviewSortCol).Add(listviewSortAdorner);
listviewIssues.Items.SortDescriptions.Add(new SortDescription(sortBy, newDir));
}
}
示例3: InnerListColumn
/// <summary>
/// Initializes a new instance of <see cref="InnerListColumn"/> class with the specified data description and visibility.
/// </summary>
/// <param name="dataDescription">The description of the data this column is bound to.</param>
/// <param name="isVisible">Whether the column is initially visible.</param>
/// <param name="createDefaultBinding">Whether the column should create a default binding using the specified data's property.</param>
public InnerListColumn(UIPropertyGroupDescription dataDescription, bool isVisible, bool createDefaultBinding)
{
if (dataDescription == null)
{
throw new ArgumentNullException("dataDescription");
}
GridViewColumnHeader header = new GridViewColumnHeader();
header.Content = dataDescription.DisplayContent;
header.DataContext = this;
Binding automationNameBinding = new Binding("DataDescription.DisplayName");
automationNameBinding.Source = this;
header.SetBinding(AutomationProperties.NameProperty, automationNameBinding);
this.Visible = isVisible;
this.Header = header;
this.DataDescription = dataDescription;
if (createDefaultBinding)
{
var defaultBinding = new Binding(GraphicalHostReflectionWrapper.EscapeBinding(dataDescription.PropertyName));
defaultBinding.StringFormat = GetDefaultStringFormat(dataDescription.DataType);
defaultBinding.ConverterCulture = CultureInfo.CurrentCulture;
this.DisplayMemberBinding = defaultBinding;
}
}
示例4: DefaultDirection
public ListSortDirection DefaultDirection(GridViewColumnHeader header)
{
var headerText = header.Content.ToString();
if (descendingHeaders.Contains(headerText))
{
return ListSortDirection.Descending;
}
return ListSortDirection.Ascending;
}
示例5: GetListCollectionViewFromGridViewColumnHeader
private static ListCollectionView GetListCollectionViewFromGridViewColumnHeader(GridViewColumnHeader header)
{
DependencyObject p = VisualTreeHelper.GetParent(header);
while (!(p is ListView))
{
p = VisualTreeHelper.GetParent(p);
}
return (ListCollectionView)CollectionViewSource.GetDefaultView(((ListView)p).ItemsSource);
}
示例6: getDirection
private ListSortDirection getDirection(GridViewColumnHeader headerClicked)
{
if (headerClicked == _lastHeaderClicked)
{
//Reverse direction
return (_lastDirection == ListSortDirection.Ascending) ? ListSortDirection.Descending : ListSortDirection.Ascending;
}
else
{
return ListSortDirection.Ascending;
}
}
示例7: ListViewColumnHeader_Click
private void ListViewColumnHeader_Click(object sender, RoutedEventArgs e)
{
var headerClicked = e.OriginalSource as GridViewColumnHeader;
ListSortDirection direction;
if (headerClicked != null)
{
if (headerClicked.Role != GridViewColumnHeaderRole.Padding)
{
var headerTag = ((TextBlock)headerClicked.Content).Tag;
if (headerClicked != this.lastHeaderClicked)
{
direction = ListSortDirection.Ascending;
}
else
{
if (this.lastDirection == ListSortDirection.Ascending)
{
direction = ListSortDirection.Descending;
}
else
{
direction = ListSortDirection.Ascending;
}
}
this.Sort(headerTag.ToString(), direction);
if (direction == ListSortDirection.Ascending)
{
headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowUp"] as DataTemplate;
}
else
{
headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowDown"] as DataTemplate;
}
// Remove arrow from previously sorted header
if (this.lastHeaderClicked != null && this.lastHeaderClicked != headerClicked)
{
this.lastHeaderClicked.Column.HeaderTemplate = null;
}
this.lastHeaderClicked = headerClicked;
this.lastDirection = direction;
}
}
}
示例8: ItemsListViewHeader_Click
private void ItemsListViewHeader_Click(object sender, RoutedEventArgs e)
{
GridViewColumnHeader column = (sender as GridViewColumnHeader);
ListSortDirection direction = ListSortDirection.Ascending;
if (column == _lastColumn && direction == _lastDirection)
{
direction = ListSortDirection.Descending;
}
ItemsListView.Items.SortDescriptions.Clear();
ItemsListView.Items.SortDescriptions.Add(new SortDescription((string)column.Content, direction));
_lastColumn = column;
_lastDirection = direction;
}
示例9: GridViewColumnHeaderClickedHandler
void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e)
{
if (e != null)
{
GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader;
ListSortDirection direction;
if (headerClicked != null)
{
if (headerClicked.Role != GridViewColumnHeaderRole.Padding)
{
if (headerClicked != _lastHeaderClicked)
{
direction = ListSortDirection.Ascending;
}
else
{
if (_lastDirection == ListSortDirection.Ascending)
{
direction = ListSortDirection.Descending;
}
else
{
direction = ListSortDirection.Ascending;
}
}
string header = headerClicked.Column.Header as string;
int index = 0;
while ((string)UploadListViewGridView.Columns[index].Header != header) index++;
Sort(index, direction);
_lastHeaderClicked = headerClicked;
_lastDirection = direction;
}
}
}
else if (e == null && _lastHeaderClicked != null)
{
string header = _lastHeaderClicked.Column.Header as string;
int index = 0;
while ((string)UploadListViewGridView.Columns[index].Header != header) index++;
Sort(index, _lastDirection);
}
}
示例10: Sort
public void Sort(ListView listView, GridViewColumnHeader sortColumn)
{
String field = sortColumn.Tag as String;
if (_currentSortCol != null)
{
AdornerLayer.GetAdornerLayer(_currentSortCol).Remove(_sortAdorner);
listView.Items.SortDescriptions.Clear();
}
ListSortDirection newDir = ListSortDirection.Ascending;
if (_currentSortCol == sortColumn && _sortAdorner.Direction == newDir)
newDir = ListSortDirection.Descending;
_currentSortCol = sortColumn;
_sortAdorner = new SortAdorner(_currentSortCol, newDir);
AdornerLayer.GetAdornerLayer(_currentSortCol).Add(_sortAdorner);
listView.Items.SortDescriptions.Add(new SortDescription(field, newDir));
}
示例11: SortClick
private void SortClick(object sender, RoutedEventArgs e)
{
var column = sender as GridViewColumnHeader;
var propertyName = column.Tag as string;
if (_curSortCol != null) {
AdornerLayer.GetAdornerLayer(_curSortCol).Remove(_curAdorner);
_listView.Items.SortDescriptions.Clear();
}
ListSortDirection direction = ListSortDirection.Ascending;
if (_curSortCol == column && _curAdorner.Direction == direction) {
direction = ListSortDirection.Descending;
}
_curSortCol = column;
_curAdorner = new SortAdorner(_curSortCol, direction);
AdornerLayer.GetAdornerLayer(_curSortCol).Add(_curAdorner);
_listView.Items.SortDescriptions.Add(new SortDescription(propertyName, direction));
}
示例12: SortClick
private void SortClick(object sender, RoutedEventArgs e)
{
GridViewColumnHeader column = sender as GridViewColumnHeader;
String field = column.Tag as String;
if (_CurSortCol != null)
{
AdornerLayer.GetAdornerLayer(_CurSortCol).Remove(_CurAdorner);
NetworkList.Items.SortDescriptions.Clear();
}
ListSortDirection newDir = ListSortDirection.Ascending;
if (_CurSortCol == column && _CurAdorner.Direction == newDir)
newDir = ListSortDirection.Descending;
_CurSortCol = column;
_CurAdorner = new SortAdorner(_CurSortCol, newDir);
AdornerLayer.GetAdornerLayer(_CurSortCol).Add(_CurAdorner);
NetworkList.Items.SortDescriptions.Add(
new SortDescription(field, newDir));
}
示例13: SortClick
private void SortClick(object sender, RoutedEventArgs e)
{
ViewModel.MainViewModel vm = DataContext as ViewModel.MainViewModel;
GridViewColumnHeader column = sender as GridViewColumnHeader;
String field = column.Tag as String;
if (m_current_sort_column != null)
{
AdornerLayer.GetAdornerLayer(m_current_sort_column).Remove(_CurAdorner);
m_entrylist.Items.SortDescriptions.Clear();
}
ListSortDirection newDir = ListSortDirection.Ascending;
if (m_current_sort_column == column && _CurAdorner.Direction == newDir)
newDir = ListSortDirection.Descending;
m_current_sort_column = column;
_CurAdorner = new SortAdorner(m_current_sort_column, newDir);
AdornerLayer.GetAdornerLayer(m_current_sort_column).Add(_CurAdorner);
m_entrylist.Items.SortDescriptions.Add(new SortDescription(field, newDir));
}
示例14: GridViewColumnHeaderClickedHandler
private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e)
{
GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader;
ListSortDirection direction;
if (headerClicked != null &&
headerClicked.Role != GridViewColumnHeaderRole.Padding)
{
if (headerClicked != _lastHeaderClicked)
{
direction = ListSortDirection.Ascending;
}
else
{
if (_lastDirection == ListSortDirection.Ascending)
{
direction = ListSortDirection.Descending;
}
else
{
direction = ListSortDirection.Ascending;
}
}
// see if we have an attached SortPropertyName value
string sortBy = GetSortPropertyName(headerClicked.Column);
if (string.IsNullOrEmpty(sortBy))
{
// otherwise use the column header name
sortBy = headerClicked.Column.Header as string;
}
Sort(sortBy, direction);
_lastHeaderClicked = headerClicked;
_lastDirection = direction;
}
}
示例15: GridViewColumnHeaderClickedHandler
private static void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e)
{
var headerClicked = e.OriginalSource as GridViewColumnHeader;
if (headerClicked != null)
{
ListSortDirection direction;
if (!Equals(headerClicked, _lastHeaderClicked))
{
direction = ListSortDirection.Ascending;
}
else
{
direction = _lastDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending;
}
string header = String.Empty;
try
{
header = ((Binding)GetSortBindingMember(headerClicked.Column)).Path.Path;
}
catch (Exception)
{
}
if (header == String.Empty)
return;
Sort(header, direction);
string resourceTypeName = String.Empty;
//if (_lastHeaderClicked != null)
//{
// ResourceTypeName = "HeaderTemplateSortNon";
// tmpTemplate = lv.TryFindResource(ResourceTypeName) as DataTemplate;
// _lastHeaderClicked.Column.HeaderTemplate = tmpTemplate;
//}
switch (direction)
{
case ListSortDirection.Ascending: resourceTypeName = "HeaderTemplateSortAsc"; break;
case ListSortDirection.Descending: resourceTypeName = "HeaderTemplateSortDesc"; break;
}
var tmpTemplate = _lv.TryFindResource(resourceTypeName) as DataTemplate;
if (tmpTemplate != null)
{
headerClicked.Column.HeaderTemplate = tmpTemplate;
}
_lastHeaderClicked = headerClicked;
_lastDirection = direction;
}
}