- crudgenerator_bin.zip
- Demo
- Demo.exe
- Demo.pdb
- NLog.dll
- Technewlogic.BusinessCore.dll
- Technewlogic.Samples.ManufacturingExecutionSystem.Backend.dll
- Technewlogic.Samples.ManufacturingExecutionSystem.Backend.pdb
- Technewlogic.Stasy.dll
- Technewlogic.Stuff.dll
- Technewlogic.WpfShell.dll
- Technewlogic.WpfShell.pdb
- Framework
- Autofac.dll
- Autofac.xml
- NLog.dll
- Technewlogic.Stuff.dll
- Technewlogic.WpfShell.dll
- WPFToolkit.dll
- crudgenerator_src.zip
- Backend
- Dependencies
- autofac-1
- Autofac.dll
- Autofac.Extras.GeneratedFactories.dll
- Autofac.Extras.GeneratedFactories.pdb
- Autofac.Integration.Wcf.dll
- Autofac.Integration.Wcf.pdb
- Autofac.Integration.Web.dll
- Autofac.Integration.Web.Mvc.dll
- Autofac.Integration.Web.Mvc.pdb
- Autofac.Integration.Web.pdb
- Autofac.pdb
- Autofac.xml
- license
- Microsoft.WpfToolkit-3.5.40128.1
- WPFToolkit.Design.dll
- WPFToolkit.dll
- WPFToolkit.VisualStudio.Design.dll
- nlog-1.0
- Technewlogic.BusinessCore-1
- Technewlogic.BusinessCore.dll
- Technewlogic.Stasy-1
- Technewlogic.Stasy.dll
- Technewlogic.Stuff-1
- Technewlogic.Stuff.dll
- WpfGui
- WpfShell.sln
- WpfShell
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Collections.Specialized;
using System.Windows;
using System.ComponentModel;
using System.Windows.Data;
namespace Technewlogic.WpfShell.UI.Controls
{
public class SortListView : ListView
{
static SortListView()
{
DefaultStyleKeyProperty.OverrideMetadata(
typeof(SortListView),
new FrameworkPropertyMetadata(typeof(SortListView)));
}
public SortListView()
{
_headerClickHandler = new RoutedEventHandler(GridViewColumnHeader_Click);
}
private RoutedEventHandler _headerClickHandler;
private ListSortDirection _lastDirection = ListSortDirection.Ascending;
#region DefaultItemsContainerStyle
public Style DefaultItemsContainerStyle
{
get { return (Style)GetValue(DefaultItemsContainerStyleProperty); }
set { SetValue(DefaultItemsContainerStyleProperty, value); }
}
// Using a DependencyProperty as the backing store for DefaultItemsContainerStyle. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DefaultItemsContainerStyleProperty =
DependencyProperty.Register("DefaultItemsContainerStyle", typeof(Style), typeof(SortListView),
new UIPropertyMetadata(null, new PropertyChangedCallback((s, e) =>
{
var me = s as SortListView;
me.ItemContainerStyle = e.NewValue as Style;
})));
#endregion
public override void EndInit()
{
base.EndInit();
var gridView = View as GridView;
if (gridView != null)
gridView.Columns.CollectionChanged += new NotifyCollectionChangedEventHandler(GridViewColumns_CollectionChanged);
}
void GridViewColumns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (var it in e.NewItems)
{
var header = GetGridViewColumnHeader(it);
if (header != null)
header.Click += _headerClickHandler;
}
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (var it in e.OldItems)
{
var header = GetGridViewColumnHeader(it);
if (header != null)
header.Click -= _headerClickHandler;
}
}
}
private GridViewColumnHeader GetGridViewColumnHeader(object gridViewColumn)
{
var column = gridViewColumn as GridViewColumn;
if (column != null)
return column.Header as GridViewColumnHeader;
else
return null;
}
void GridViewColumnHeader_Click(object sender, System.Windows.RoutedEventArgs e)
{
GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader;
if (headerClicked != null)
{
if (headerClicked.Role != GridViewColumnHeaderRole.Padding)
{
if (_lastDirection == ListSortDirection.Ascending)
_lastDirection = ListSortDirection.Descending;
else
_lastDirection = ListSortDirection.Ascending;
Sort(headerClicked.Name, _lastDirection);
}
}
}
private void Sort(string sortBy, ListSortDirection direction)
{
ICollectionView dataView = CollectionViewSource.GetDefaultView(ItemsSource);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.