Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4989 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
12 changed files with 473 additions and 149 deletions
@ -1,29 +1,52 @@ |
|||||||
<UserControl x:Class="ICSharpCode.StartPage.RecentProjectsControl" |
<?xml version="1.0" encoding="utf-8"?> |
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
<UserControl |
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
x:Class="ICSharpCode.StartPage.RecentProjectsControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="http://icsharpcode.net/sharpdevelop/core"> |
||||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core"> |
<StackPanel |
||||||
<StackPanel Orientation="Vertical"> |
Orientation="Vertical"> |
||||||
<ListView Name="lastProjectsListView" SelectionMode="Single" MouseDoubleClick="lastProjectsDoubleClick" KeyDown="lastProjectsKeyDown"> |
<ListView |
||||||
|
Name="lastProjectsListView" |
||||||
|
SelectionMode="Single" |
||||||
|
core:SortableGridViewColumn.SortMode="Automatic" |
||||||
|
MouseDoubleClick="lastProjectsDoubleClick" |
||||||
|
KeyDown="lastProjectsKeyDown"> |
||||||
<ListView.Resources> |
<ListView.Resources> |
||||||
<DataTemplate x:Key="nameCellTemplate"> |
<DataTemplate |
||||||
|
x:Key="nameCellTemplate"> |
||||||
<TextBlock> |
<TextBlock> |
||||||
<Hyperlink Tag="{Binding}" Click="listViewHyperlinkClick"> |
<Hyperlink |
||||||
<TextBlock Text="{Binding Path=Name}" /> |
Tag="{Binding}" |
||||||
|
Click="listViewHyperlinkClick"> |
||||||
|
<TextBlock |
||||||
|
Text="{Binding Path=Name}" /> |
||||||
</Hyperlink> |
</Hyperlink> |
||||||
</TextBlock> |
</TextBlock> |
||||||
</DataTemplate> |
</DataTemplate> |
||||||
</ListView.Resources> |
</ListView.Resources> |
||||||
<ListView.View> |
<ListView.View> |
||||||
<GridView> |
<GridView> |
||||||
<GridViewColumn CellTemplate="{StaticResource nameCellTemplate}" Header="{core:Localize Global.Name}" /> |
<core:SortableGridViewColumn |
||||||
<GridViewColumn DisplayMemberBinding="{Binding Path=LastModification}" Header="{core:Localize StartPage.StartMenu.ModifiedTable}" /> |
SortBy="Name" |
||||||
<GridViewColumn DisplayMemberBinding="{Binding Path=Path}" Header="{core:Localize StartPage.StartMenu.LocationTable}" /> |
CellTemplate="{StaticResource nameCellTemplate}" |
||||||
|
Header="{core:Localize Global.Name}" /> |
||||||
|
<core:SortableGridViewColumn |
||||||
|
DisplayMemberBinding="{Binding Path=LastModification}" |
||||||
|
Header="{core:Localize StartPage.StartMenu.ModifiedTable}" /> |
||||||
|
<core:SortableGridViewColumn |
||||||
|
DisplayMemberBinding="{Binding Path=Path}" |
||||||
|
Header="{core:Localize StartPage.StartMenu.LocationTable}" /> |
||||||
</GridView> |
</GridView> |
||||||
</ListView.View> |
</ListView.View> |
||||||
</ListView> |
</ListView> |
||||||
<StackPanel Orientation="Horizontal" Margin="0,20,0,0"> |
<StackPanel |
||||||
<Button Content="{core:Localize StartPage.StartMenu.OpenCombineButton}" Click="openSolutionClick" /> |
Orientation="Horizontal" |
||||||
<Button Content="{core:Localize StartPage.StartMenu.NewCombineButton}" Click="newSolutionClick" Margin="8,0,0,0" /> |
Margin="0,20,0,0"> |
||||||
|
<Button |
||||||
|
Content="{core:Localize StartPage.StartMenu.OpenCombineButton}" |
||||||
|
Click="openSolutionClick" /> |
||||||
|
<Button |
||||||
|
Content="{core:Localize StartPage.StartMenu.NewCombineButton}" |
||||||
|
Click="newSolutionClick" |
||||||
|
Margin="8,0,0,0" /> |
||||||
</StackPanel> |
</StackPanel> |
||||||
</StackPanel> |
</StackPanel> |
||||||
</UserControl> |
</UserControl> |
||||||
@ -1,113 +1,119 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||||
<UserControl |
<UserControl |
||||||
x:ClassModifier="internal" |
x:ClassModifier="internal" |
||||||
x:Class="ICSharpCode.SharpDevelop.Project.Converter.UpgradeView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
x:Class="ICSharpCode.SharpDevelop.Project.Converter.UpgradeView" |
||||||
<Grid> |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
<Grid.RowDefinitions> |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
<RowDefinition |
xmlns:core="http://icsharpcode.net/sharpdevelop/core"> |
||||||
Height="Auto" /> |
<Grid> |
||||||
<RowDefinition |
<Grid.RowDefinitions> |
||||||
Height="*" /> |
<RowDefinition |
||||||
<RowDefinition |
Height="Auto" /> |
||||||
Height="Auto" /> |
<RowDefinition |
||||||
<RowDefinition |
Height="*" /> |
||||||
Height="Auto" /> |
<RowDefinition |
||||||
</Grid.RowDefinitions> |
Height="Auto" /> |
||||||
<TextBlock |
<RowDefinition |
||||||
Grid.Column="0" |
Height="Auto" /> |
||||||
Grid.Row="0" |
</Grid.RowDefinitions> |
||||||
Margin="8,8,8,4"> |
<TextBlock |
||||||
This solution was created using a previous version of SharpDevelop. |
Grid.Column="0" |
||||||
You might want to upgrade it so that you can use new language or framework features. |
Grid.Row="0" |
||||||
</TextBlock> |
TextWrapping="WrapWithOverflow" |
||||||
<ListView |
Margin="8,8,8,4"> |
||||||
x:Name="listView" |
This solution was created using a previous version of SharpDevelop. |
||||||
Grid.Column="0" |
You might want to upgrade it so that you can use new language or framework features. |
||||||
Grid.Row="1" |
</TextBlock> |
||||||
Margin="8,4,8,4" |
<ListView |
||||||
SelectionMode="Multiple" |
x:Name="listView" |
||||||
SelectionChanged="ListView_SelectionChanged"> |
core:SortableGridViewColumn.SortMode="Automatic" |
||||||
<ListView.View> |
Grid.Column="0" |
||||||
<GridView> |
Grid.Row="1" |
||||||
<GridViewColumn |
Margin="8,4,8,4" |
||||||
Header="Project"> |
SelectionMode="Multiple" |
||||||
<GridViewColumn.CellTemplate> |
SelectionChanged="ListView_SelectionChanged"> |
||||||
<DataTemplate> |
<ListView.View> |
||||||
<CheckBox |
<GridView> |
||||||
Content="{Binding Name}" |
<core:SortableGridViewColumn |
||||||
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" /> |
SortBy="Name" |
||||||
</DataTemplate> |
Header="Project"> |
||||||
</GridViewColumn.CellTemplate> |
<GridViewColumn.CellTemplate> |
||||||
</GridViewColumn> |
<DataTemplate> |
||||||
<GridViewColumn |
<CheckBox |
||||||
DisplayMemberBinding="{Binding CompilerVersionName}" |
Content="{Binding Name}" |
||||||
Header="Compiler Version" /> |
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" /> |
||||||
<GridViewColumn |
</DataTemplate> |
||||||
DisplayMemberBinding="{Binding TargetFrameworkName}" |
</GridViewColumn.CellTemplate> |
||||||
Header="Target Framework" /> |
</core:SortableGridViewColumn> |
||||||
</GridView> |
<core:SortableGridViewColumn |
||||||
</ListView.View> |
DisplayMemberBinding="{Binding CompilerVersionName}" |
||||||
</ListView> |
Header="Compiler Version" /> |
||||||
<CheckBox |
<core:SortableGridViewColumn |
||||||
Content="Select _all" |
DisplayMemberBinding="{Binding TargetFrameworkName}" |
||||||
Grid.Row="2" |
Header="Target Framework" /> |
||||||
Name="selectAllCheckBox" |
</GridView> |
||||||
Checked="SelectAllCheckBox_Checked" |
</ListView.View> |
||||||
Unchecked="SelectAllCheckBox_Unchecked" |
</ListView> |
||||||
HorizontalAlignment="Left" |
<CheckBox |
||||||
Margin="10,0,0,0" /> |
Content="Select _all" |
||||||
<GroupBox |
Grid.Row="2" |
||||||
Grid.Column="0" |
Name="selectAllCheckBox" |
||||||
Grid.Row="3" |
Checked="SelectAllCheckBox_Checked" |
||||||
HorizontalAlignment="Stretch" |
Unchecked="SelectAllCheckBox_Unchecked" |
||||||
VerticalAlignment="Stretch" |
HorizontalAlignment="Left" |
||||||
Margin="8,0,8,8" |
Margin="10,0,0,0" /> |
||||||
Header="Change version of selected projects"> |
<GroupBox |
||||||
<Grid |
Grid.Column="0" |
||||||
Margin="4"> |
Grid.Row="3" |
||||||
<Grid.RowDefinitions> |
HorizontalAlignment="Stretch" |
||||||
<RowDefinition |
VerticalAlignment="Stretch" |
||||||
Height="Auto" /> |
Margin="8,0,8,8" |
||||||
<RowDefinition |
Header="Change version of selected projects"> |
||||||
Height="Auto" /> |
<Grid |
||||||
<RowDefinition |
Margin="4"> |
||||||
Height="Auto" /> |
<Grid.RowDefinitions> |
||||||
</Grid.RowDefinitions> |
<RowDefinition |
||||||
<Grid.ColumnDefinitions> |
Height="Auto" /> |
||||||
<ColumnDefinition |
<RowDefinition |
||||||
Width="Auto" /> |
Height="Auto" /> |
||||||
<ColumnDefinition |
<RowDefinition |
||||||
Width="120" /> |
Height="Auto" /> |
||||||
</Grid.ColumnDefinitions> |
</Grid.RowDefinitions> |
||||||
<Label |
<Grid.ColumnDefinitions> |
||||||
Content="Convert selected _projects to:" |
<ColumnDefinition |
||||||
Grid.Column="0" |
Width="Auto" /> |
||||||
Grid.Row="0" |
<ColumnDefinition |
||||||
Target="{Binding ElementName=newVersionComboBox}" /> |
Width="120" /> |
||||||
<ComboBox |
</Grid.ColumnDefinitions> |
||||||
Name="newVersionComboBox" |
<Label |
||||||
Grid.Column="1" |
Content="Convert selected _projects to:" |
||||||
Grid.Row="0" |
Grid.Column="0" |
||||||
Height="22" /> |
Grid.Row="0" |
||||||
<Label |
Target="{Binding ElementName=newVersionComboBox}" /> |
||||||
Content="Change _target framework:" |
<ComboBox |
||||||
Grid.Column="0" |
Name="newVersionComboBox" |
||||||
Grid.Row="1" |
Grid.Column="1" |
||||||
Target="{Binding ElementName=newFrameworkComboBox}" /> |
Grid.Row="0" |
||||||
<ComboBox |
Height="22" /> |
||||||
Name="newFrameworkComboBox" |
<Label |
||||||
Grid.Column="1" |
Content="Change _target framework:" |
||||||
Grid.Row="1" |
Grid.Column="0" |
||||||
Height="22" /> |
Grid.Row="1" |
||||||
<Button |
Target="{Binding ElementName=newFrameworkComboBox}" /> |
||||||
Name="convertButton" |
<ComboBox |
||||||
Width="90" |
Name="newFrameworkComboBox" |
||||||
Height="22" |
Grid.Column="1" |
||||||
Content="_Convert" |
Grid.Row="1" |
||||||
Grid.Column="0" |
Height="22" /> |
||||||
Grid.ColumnSpan="2" |
<Button |
||||||
Grid.Row="2" /> |
Name="convertButton" |
||||||
</Grid> |
Width="90" |
||||||
</GroupBox> |
Height="22" |
||||||
</Grid> |
Content="_Convert" |
||||||
|
Grid.Column="0" |
||||||
|
Grid.ColumnSpan="2" |
||||||
|
Grid.Row="2" /> |
||||||
|
</Grid> |
||||||
|
</GroupBox> |
||||||
|
</Grid> |
||||||
</UserControl> |
</UserControl> |
||||||
@ -0,0 +1,65 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Markup; |
||||||
|
|
||||||
|
namespace ICSharpCode.Core.Presentation |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// ExtensionMethods that help with WPF.
|
||||||
|
/// </summary>
|
||||||
|
public static class ExtensionMethods |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Sets the value of a dependency property on <paramref name="targetObject"/> using a markup extension.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This method does not support markup extensions like x:Static that depend on
|
||||||
|
/// having a XAML file as context.</remarks>
|
||||||
|
public static void SetValueToExtension(this DependencyObject targetObject, DependencyProperty property, MarkupExtension markupExtension) |
||||||
|
{ |
||||||
|
if (targetObject == null) |
||||||
|
throw new ArgumentNullException("targetObject"); |
||||||
|
if (property == null) |
||||||
|
throw new ArgumentNullException("property"); |
||||||
|
if (markupExtension == null) |
||||||
|
throw new ArgumentNullException("markupExtension"); |
||||||
|
|
||||||
|
var serviceProvider = new SetValueToExtensionServiceProvider(targetObject, property); |
||||||
|
targetObject.SetValue(property, markupExtension.ProvideValue(serviceProvider)); |
||||||
|
} |
||||||
|
|
||||||
|
sealed class SetValueToExtensionServiceProvider : IServiceProvider, IProvideValueTarget |
||||||
|
{ |
||||||
|
readonly DependencyObject targetObject; |
||||||
|
readonly DependencyProperty targetProperty; |
||||||
|
|
||||||
|
public SetValueToExtensionServiceProvider(DependencyObject targetObject, DependencyProperty property) |
||||||
|
{ |
||||||
|
this.targetObject = targetObject; |
||||||
|
this.targetProperty = property; |
||||||
|
} |
||||||
|
|
||||||
|
public object GetService(Type serviceType) |
||||||
|
{ |
||||||
|
if (serviceType == typeof(IProvideValueTarget)) |
||||||
|
return this; |
||||||
|
else |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public object TargetObject { |
||||||
|
get { return targetObject; } |
||||||
|
} |
||||||
|
|
||||||
|
public object TargetProperty { |
||||||
|
get { return targetProperty; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,212 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
|
||||||
|
namespace ICSharpCode.Core.Presentation |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Allows to automatically sort a grid view.
|
||||||
|
/// </summary>
|
||||||
|
public class SortableGridViewColumn : GridViewColumn |
||||||
|
{ |
||||||
|
static readonly ComponentResourceKey headerTemplateKey = new ComponentResourceKey(typeof(SortableGridViewColumn), "ColumnHeaderTemplate"); |
||||||
|
|
||||||
|
public SortableGridViewColumn() |
||||||
|
{ |
||||||
|
this.SetValueToExtension(HeaderTemplateProperty, new DynamicResourceExtension(headerTemplateKey)); |
||||||
|
} |
||||||
|
|
||||||
|
string sortBy; |
||||||
|
|
||||||
|
public string SortBy { |
||||||
|
get { return sortBy; } |
||||||
|
set { |
||||||
|
if (sortBy != value) { |
||||||
|
sortBy = value; |
||||||
|
OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("SortBy")); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#region SortDirection property
|
||||||
|
public static readonly DependencyProperty SortDirectionProperty = |
||||||
|
DependencyProperty.RegisterAttached("SortDirection", typeof(ColumnSortDirection), typeof(SortableGridViewColumn), |
||||||
|
new FrameworkPropertyMetadata(ColumnSortDirection.None, OnSortDirectionChanged)); |
||||||
|
|
||||||
|
public ColumnSortDirection SortDirection { |
||||||
|
get { return (ColumnSortDirection)GetValue(SortDirectionProperty); } |
||||||
|
set { SetValue(SortDirectionProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public static ColumnSortDirection GetSortDirection(ListView listView) |
||||||
|
{ |
||||||
|
return (ColumnSortDirection)listView.GetValue(SortDirectionProperty); |
||||||
|
} |
||||||
|
|
||||||
|
public static void SetSortDirection(ListView listView, ColumnSortDirection value) |
||||||
|
{ |
||||||
|
listView.SetValue(SortDirectionProperty, value); |
||||||
|
} |
||||||
|
|
||||||
|
static void OnSortDirectionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) |
||||||
|
{ |
||||||
|
ListView grid = sender as ListView; |
||||||
|
if (grid != null) { |
||||||
|
SortableGridViewColumn col = GetCurrentSortColumn(grid); |
||||||
|
if (col != null) |
||||||
|
col.SortDirection = (ColumnSortDirection)args.NewValue; |
||||||
|
Sort(grid); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CurrentSortColumn property
|
||||||
|
public static readonly DependencyProperty CurrentSortColumnProperty = |
||||||
|
DependencyProperty.RegisterAttached("CurrentSortColumn", typeof(SortableGridViewColumn), typeof(SortableGridViewColumn), |
||||||
|
new FrameworkPropertyMetadata(OnCurrentSortColumnChanged)); |
||||||
|
|
||||||
|
public static SortableGridViewColumn GetCurrentSortColumn(ListView listView) |
||||||
|
{ |
||||||
|
return (SortableGridViewColumn)listView.GetValue(CurrentSortColumnProperty); |
||||||
|
} |
||||||
|
|
||||||
|
public static void SetCurrentSortColumn(ListView listView, SortableGridViewColumn value) |
||||||
|
{ |
||||||
|
listView.SetValue(CurrentSortColumnProperty, value); |
||||||
|
} |
||||||
|
|
||||||
|
static void OnCurrentSortColumnChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) |
||||||
|
{ |
||||||
|
ListView grid = sender as ListView; |
||||||
|
if (grid != null) { |
||||||
|
SortableGridViewColumn oldColumn = (SortableGridViewColumn)args.OldValue; |
||||||
|
if (oldColumn != null) |
||||||
|
oldColumn.SortDirection = ColumnSortDirection.None; |
||||||
|
SortableGridViewColumn newColumn = (SortableGridViewColumn)args.NewValue; |
||||||
|
if (newColumn != null) { |
||||||
|
newColumn.SortDirection = GetSortDirection(grid); |
||||||
|
} |
||||||
|
Sort(grid); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region SortMode property
|
||||||
|
public static readonly DependencyProperty SortModeProperty = |
||||||
|
DependencyProperty.RegisterAttached("SortMode", typeof(ListViewSortMode), typeof(SortableGridViewColumn), |
||||||
|
new FrameworkPropertyMetadata(ListViewSortMode.None, OnSortModeChanged)); |
||||||
|
|
||||||
|
public static ListViewSortMode GetSortMode(ListView listView) |
||||||
|
{ |
||||||
|
return (ListViewSortMode)listView.GetValue(SortModeProperty); |
||||||
|
} |
||||||
|
|
||||||
|
public static void SetSortMode(ListView listView, ListViewSortMode value) |
||||||
|
{ |
||||||
|
listView.SetValue(SortModeProperty, value); |
||||||
|
} |
||||||
|
|
||||||
|
static void OnSortModeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) |
||||||
|
{ |
||||||
|
ListView grid = sender as ListView; |
||||||
|
if (grid != null) { |
||||||
|
if ((ListViewSortMode)args.NewValue != ListViewSortMode.None) |
||||||
|
grid.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickHandler)); |
||||||
|
else |
||||||
|
grid.RemoveHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickHandler)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static void GridViewColumnHeaderClickHandler(object sender, RoutedEventArgs e) |
||||||
|
{ |
||||||
|
ListView grid = sender as ListView; |
||||||
|
GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader; |
||||||
|
if (grid != null && headerClicked != null && headerClicked.Role != GridViewColumnHeaderRole.Padding) { |
||||||
|
if (headerClicked.Column == GetCurrentSortColumn(grid)) { |
||||||
|
if (GetSortDirection(grid) == ColumnSortDirection.Ascending) |
||||||
|
SetSortDirection(grid, ColumnSortDirection.Descending); |
||||||
|
else |
||||||
|
SetSortDirection(grid, ColumnSortDirection.Ascending); |
||||||
|
} else { |
||||||
|
SetSortDirection(grid, ColumnSortDirection.Ascending); |
||||||
|
SetCurrentSortColumn(grid, headerClicked.Column as SortableGridViewColumn); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
static void Sort(ListView grid) |
||||||
|
{ |
||||||
|
ColumnSortDirection currentDirection = GetSortDirection(grid); |
||||||
|
SortableGridViewColumn column = GetCurrentSortColumn(grid); |
||||||
|
if (column != null && GetSortMode(grid) == ListViewSortMode.Automatic && currentDirection != ColumnSortDirection.None) { |
||||||
|
ICollectionView dataView = CollectionViewSource.GetDefaultView(grid.ItemsSource); |
||||||
|
|
||||||
|
string sortBy = column.SortBy; |
||||||
|
if (sortBy == null) { |
||||||
|
Binding binding = column.DisplayMemberBinding as Binding; |
||||||
|
if (binding != null && binding.Path != null) { |
||||||
|
sortBy = binding.Path.Path; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dataView.SortDescriptions.Clear(); |
||||||
|
if (sortBy != null) { |
||||||
|
ListSortDirection direction; |
||||||
|
if (currentDirection == ColumnSortDirection.Descending) |
||||||
|
direction = ListSortDirection.Descending; |
||||||
|
else |
||||||
|
direction = ListSortDirection.Ascending; |
||||||
|
dataView.SortDescriptions.Add(new SortDescription(sortBy, direction)); |
||||||
|
} |
||||||
|
dataView.Refresh(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public enum ColumnSortDirection |
||||||
|
{ |
||||||
|
None, |
||||||
|
Ascending, |
||||||
|
Descending |
||||||
|
} |
||||||
|
|
||||||
|
public enum ListViewSortMode |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Disable automatic sorting when sortable columns are clicked.
|
||||||
|
/// </summary>
|
||||||
|
None, |
||||||
|
/// <summary>
|
||||||
|
/// Fully automatic sorting.
|
||||||
|
/// </summary>
|
||||||
|
Automatic, |
||||||
|
/// <summary>
|
||||||
|
/// Automatically update SortDirection and CurrentSortColumn properties,
|
||||||
|
/// but do not actually sort the data.
|
||||||
|
/// </summary>
|
||||||
|
HalfAutomatic |
||||||
|
} |
||||||
|
|
||||||
|
sealed class ColumnSortDirectionToVisibilityConverter : IValueConverter |
||||||
|
{ |
||||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||||
|
{ |
||||||
|
return Equals(value, parameter) ? Visibility.Visible : Visibility.Collapsed; |
||||||
|
} |
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||||
|
{ |
||||||
|
throw new NotSupportedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue