本文整理汇总了C#中System.Windows.Controls.GridViewColumnHeader.HasValue方法的典型用法代码示例。如果您正苦于以下问题:C# GridViewColumnHeader.HasValue方法的具体用法?C# GridViewColumnHeader.HasValue怎么用?C# GridViewColumnHeader.HasValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.GridViewColumnHeader
的用法示例。
在下文中一共展示了GridViewColumnHeader.HasValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridViewColumnHeaderClicked
public static void GridViewColumnHeaderClicked(ListView listView, GridViewColumnHeader clickedHeader)
{
if (!clickedHeader.HasValue()) return;
if (clickedHeader.Role == GridViewColumnHeaderRole.Padding) return;
ListSortDirection direction;
if (!Equals(clickedHeader, _lastHeaderClicked))
{
direction = ListSortDirection.Descending;
}
else
{
if (_lastDirection == ListSortDirection.Ascending)
{
direction = ListSortDirection.Descending;
}
else
{
direction = ListSortDirection.Ascending;
}
}
string sortString = null;
if (clickedHeader.Column.DisplayMemberBinding.HasValue())
{
sortString = ((Binding) clickedHeader.Column.DisplayMemberBinding).Path.Path;
}
else
{
var stackPanel = clickedHeader.Column.CellTemplate.LoadContent() as StackPanel;
foreach (object item in stackPanel.Children)
{
if (item is TextBlock)
{
sortString =
BindingOperations.GetBinding((item as TextBlock), TextBlock.TextProperty).Path.Path;
break;
}
}
}
Sort(listView, sortString, direction);
// Remove arrow from previously sorted header
if (_lastHeaderClicked.HasValue() && _lastHeaderClicked != clickedHeader)
{
_lastHeaderClicked.Column.HeaderTemplate = null;
}
if (!_lastHeaderClicked.HasValue())
(listView.View as GridView).Columns[1].HeaderTemplate = null;
if (direction == ListSortDirection.Ascending)
{
if (_arrowUp.HasValue())
clickedHeader.Column.HeaderTemplate = _arrowUp;
}
else
{
if (_arrowDown.HasValue())
clickedHeader.Column.HeaderTemplate = _arrowDown;
}
_lastHeaderClicked = clickedHeader;
_lastDirection = direction;
}