Browse Source

Add sorting support to WPF ListViews.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4989 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
cf8be1851d
  1. 53
      src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml
  2. 2
      src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs
  3. 9
      src/AddIns/Misc/StartPage/Project/Src/StartPageControl.xaml
  4. 2
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonPadContent.cs
  5. 226
      src/Main/Base/Project/Src/Project/Converter/UpgradeView.xaml
  6. 16
      src/Main/Base/Project/Src/TextEditor/Commands/ToolCommands.cs
  7. 65
      src/Main/ICSharpCode.Core.Presentation/ExtensionMethods.cs
  8. 2
      src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj
  9. 5
      src/Main/ICSharpCode.Core.Presentation/LocalizeExtension.cs
  10. 212
      src/Main/ICSharpCode.Core.Presentation/SortableGridViewColumn.cs
  11. 1
      src/Main/ICSharpCode.Core.Presentation/themes/Aero.NormalColor.xaml
  12. 29
      src/Main/ICSharpCode.Core.Presentation/themes/generic.xaml

53
src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml

@ -1,29 +1,52 @@ @@ -1,29 +1,52 @@
<UserControl 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">
<StackPanel Orientation="Vertical">
<ListView Name="lastProjectsListView" SelectionMode="Single" MouseDoubleClick="lastProjectsDoubleClick" KeyDown="lastProjectsKeyDown">
<?xml version="1.0" encoding="utf-8"?>
<UserControl
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">
<StackPanel
Orientation="Vertical">
<ListView
Name="lastProjectsListView"
SelectionMode="Single"
core:SortableGridViewColumn.SortMode="Automatic"
MouseDoubleClick="lastProjectsDoubleClick"
KeyDown="lastProjectsKeyDown">
<ListView.Resources>
<DataTemplate x:Key="nameCellTemplate">
<DataTemplate
x:Key="nameCellTemplate">
<TextBlock>
<Hyperlink Tag="{Binding}" Click="listViewHyperlinkClick">
<TextBlock Text="{Binding Path=Name}" />
<Hyperlink
Tag="{Binding}"
Click="listViewHyperlinkClick">
<TextBlock
Text="{Binding Path=Name}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn CellTemplate="{StaticResource nameCellTemplate}" Header="{core:Localize Global.Name}" />
<GridViewColumn DisplayMemberBinding="{Binding Path=LastModification}" Header="{core:Localize StartPage.StartMenu.ModifiedTable}" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Path}" Header="{core:Localize StartPage.StartMenu.LocationTable}" />
<core:SortableGridViewColumn
SortBy="Name"
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>
</ListView.View>
</ListView>
<StackPanel Orientation="Horizontal" 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
Orientation="Horizontal"
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>
</UserControl>

2
src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.StartPage @@ -28,7 +28,7 @@ namespace ICSharpCode.StartPage
{
InitializeComponent();
SetBinding(HeaderProperty, new LocalizeExtension("StartPage.StartMenu.BarNameName").CreateBinding());
this.SetValueToExtension(HeaderProperty, new LocalizeExtension("StartPage.StartMenu.BarNameName"));
BuildRecentProjectList();
}

9
src/AddIns/Misc/StartPage/Project/Src/StartPageControl.xaml

@ -73,11 +73,14 @@ @@ -73,11 +73,14 @@
Background="#A8C6E3"
Grid.Row="2"
Padding="4,0,4,0"
TextWrapping="Wrap">
TextWrapping="WrapWithOverflow">
Copyright ©2000-2009
<Hyperlink
NavigateUri="mailto:webmaster@icsharpcode.net">IC#SharpCode</Hyperlink><Run
Text="{x:Static gui:AboutSharpDevelopTabPage.LicenseSentence}" /></TextBlock>
NavigateUri="mailto:webmaster@icsharpcode.net">IC#SharpCode</Hyperlink>
<Run Text=" "/>
<Run
Text="{x:Static gui:AboutSharpDevelopTabPage.LicenseSentence}" />
</TextBlock>
</Grid>
</ScrollViewer>
</UserControl>

2
src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonPadContent.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Gui
this.layout = layout;
this.Name = descriptor.Class.Replace('.', '_');
this.SetBinding(TitleProperty, new StringParseExtension(descriptor.Title).CreateBinding());
this.SetValueToExtension(TitleProperty, new StringParseExtension(descriptor.Title));
placeholder = new TextBlock { Text = this.Title };
this.Content = placeholder;
this.Icon = PresentationResourceService.GetPixelSnappedImage(descriptor.Icon);

226
src/Main/Base/Project/Src/Project/Converter/UpgradeView.xaml

@ -1,113 +1,119 @@ @@ -1,113 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="*" />
<RowDefinition
Height="Auto" />
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Column="0"
Grid.Row="0"
Margin="8,8,8,4">
This solution was created using a previous version of SharpDevelop.
You might want to upgrade it so that you can use new language or framework features.
</TextBlock>
<ListView
x:Name="listView"
Grid.Column="0"
Grid.Row="1"
Margin="8,4,8,4"
SelectionMode="Multiple"
SelectionChanged="ListView_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn
Header="Project">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox
Content="{Binding Name}"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn
DisplayMemberBinding="{Binding CompilerVersionName}"
Header="Compiler Version" />
<GridViewColumn
DisplayMemberBinding="{Binding TargetFrameworkName}"
Header="Target Framework" />
</GridView>
</ListView.View>
</ListView>
<CheckBox
Content="Select _all"
Grid.Row="2"
Name="selectAllCheckBox"
Checked="SelectAllCheckBox_Checked"
Unchecked="SelectAllCheckBox_Unchecked"
HorizontalAlignment="Left"
Margin="10,0,0,0" />
<GroupBox
Grid.Column="0"
Grid.Row="3"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="8,0,8,8"
Header="Change version of selected projects">
<Grid
Margin="4">
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="Auto" />
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto" />
<ColumnDefinition
Width="120" />
</Grid.ColumnDefinitions>
<Label
Content="Convert selected _projects to:"
Grid.Column="0"
Grid.Row="0"
Target="{Binding ElementName=newVersionComboBox}" />
<ComboBox
Name="newVersionComboBox"
Grid.Column="1"
Grid.Row="0"
Height="22" />
<Label
Content="Change _target framework:"
Grid.Column="0"
Grid.Row="1"
Target="{Binding ElementName=newFrameworkComboBox}" />
<ComboBox
Name="newFrameworkComboBox"
Grid.Column="1"
Grid.Row="1"
Height="22" />
<Button
Name="convertButton"
Width="90"
Height="22"
Content="_Convert"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="2" />
</Grid>
</GroupBox>
</Grid>
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"
xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="*" />
<RowDefinition
Height="Auto" />
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Column="0"
Grid.Row="0"
TextWrapping="WrapWithOverflow"
Margin="8,8,8,4">
This solution was created using a previous version of SharpDevelop.
You might want to upgrade it so that you can use new language or framework features.
</TextBlock>
<ListView
x:Name="listView"
core:SortableGridViewColumn.SortMode="Automatic"
Grid.Column="0"
Grid.Row="1"
Margin="8,4,8,4"
SelectionMode="Multiple"
SelectionChanged="ListView_SelectionChanged">
<ListView.View>
<GridView>
<core:SortableGridViewColumn
SortBy="Name"
Header="Project">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox
Content="{Binding Name}"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</core:SortableGridViewColumn>
<core:SortableGridViewColumn
DisplayMemberBinding="{Binding CompilerVersionName}"
Header="Compiler Version" />
<core:SortableGridViewColumn
DisplayMemberBinding="{Binding TargetFrameworkName}"
Header="Target Framework" />
</GridView>
</ListView.View>
</ListView>
<CheckBox
Content="Select _all"
Grid.Row="2"
Name="selectAllCheckBox"
Checked="SelectAllCheckBox_Checked"
Unchecked="SelectAllCheckBox_Unchecked"
HorizontalAlignment="Left"
Margin="10,0,0,0" />
<GroupBox
Grid.Column="0"
Grid.Row="3"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="8,0,8,8"
Header="Change version of selected projects">
<Grid
Margin="4">
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="Auto" />
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto" />
<ColumnDefinition
Width="120" />
</Grid.ColumnDefinitions>
<Label
Content="Convert selected _projects to:"
Grid.Column="0"
Grid.Row="0"
Target="{Binding ElementName=newVersionComboBox}" />
<ComboBox
Name="newVersionComboBox"
Grid.Column="1"
Grid.Row="0"
Height="22" />
<Label
Content="Change _target framework:"
Grid.Column="0"
Grid.Row="1"
Target="{Binding ElementName=newFrameworkComboBox}" />
<ComboBox
Name="newFrameworkComboBox"
Grid.Column="1"
Grid.Row="1"
Height="22" />
<Button
Name="convertButton"
Width="90"
Height="22"
Content="_Convert"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="2" />
</Grid>
</GroupBox>
</Grid>
</UserControl>

16
src/Main/Base/Project/Src/TextEditor/Commands/ToolCommands.cs

@ -147,20 +147,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -147,20 +147,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
}
}
public class SplitTextEditor : AbstractMenuCommand
{
public override void Run()
{
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent;
if (viewContent == null || !(viewContent is ITextEditorControlProvider)) {
return;
}
TextEditorControl textEditorControl = ((ITextEditorControlProvider)viewContent).TextEditorControl;
if (textEditorControl != null) {
textEditorControl.Split();
}
}
}
}

65
src/Main/ICSharpCode.Core.Presentation/ExtensionMethods.cs

@ -0,0 +1,65 @@ @@ -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; }
}
}
}
}

2
src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj

@ -67,9 +67,11 @@ @@ -67,9 +67,11 @@
<Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="SortableGridViewColumn.cs" />
<Compile Include="CollapsiblePanel.cs" />
<Compile Include="ConditionalSeparator.cs" />
<Compile Include="DropDownButton.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="GetBitmapExtension.cs" />
<Compile Include="IOptionBindingContainer.cs" />
<Compile Include="IStatusUpdate.cs" />

5
src/Main/ICSharpCode.Core.Presentation/LocalizeExtension.cs

@ -69,18 +69,19 @@ namespace ICSharpCode.Core.Presentation @@ -69,18 +69,19 @@ namespace ICSharpCode.Core.Presentation
public override object ProvideValue(IServiceProvider serviceProvider)
{
if (UpdateOnLanguageChange) {
return CreateBinding().ProvideValue(serviceProvider);
Binding binding = new Binding("Value") { Source = this, Mode = BindingMode.OneWay };
return binding.ProvideValue(serviceProvider);
} else {
return this.Value;
}
}
[Obsolete("Use ExtensionMethods.SetValueToExtension instead of directly fetching the binding from this extension")]
public Binding CreateBinding()
{
return new Binding("Value") { Source = this, Mode = BindingMode.OneWay };
}
event System.ComponentModel.PropertyChangedEventHandler ChangedEvent;
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged {

212
src/Main/ICSharpCode.Core.Presentation/SortableGridViewColumn.cs

@ -0,0 +1,212 @@ @@ -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();
}
}
}

1
src/Main/ICSharpCode.Core.Presentation/themes/Aero.NormalColor.xaml

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.Core.Presentation"
>
<!-- Colors for DropDownButton and SplitButton -->
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}" Color="#FF3399FF"/>
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}" Color="#FFC2E0FF"/>
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:SplitButton}, PressedBackground}" Color="#FF99CCFF"/>

29
src/Main/ICSharpCode.Core.Presentation/themes/generic.xaml

@ -2,10 +2,12 @@ @@ -2,10 +2,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.Core.Presentation"
>
<!-- Colors for DropDownButton and SplitButton -->
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBorder}" Color="#FF0A246A"/>
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:DropDownButton}, ActiveBackground}" Color="#FFB6BDD2"/>
<SolidColorBrush x:Key="{ComponentResourceKey {x:Type local:SplitButton}, PressedBackground}" Color="#FF8592B5"/>
<!-- Style and Template for DropDownButton -->
<Style TargetType="{x:Type local:DropDownButton}">
<Setter Property="TextElement.Foreground" Value = "{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Control.Padding" Value="2,2,2,2"/>
@ -68,6 +70,7 @@ @@ -68,6 +70,7 @@
</Setter>
</Style>
<!-- Style and Template for SplitButton -->
<Style TargetType="{x:Type local:SplitButton}">
<Setter Property="TextElement.Foreground" Value = "{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Control.Padding" Value="2,2,2,2"/>
@ -144,7 +147,8 @@ @@ -144,7 +147,8 @@
</Setter.Value>
</Setter>
</Style>
<!-- Template for CollapsiblePanel -->
<Style TargetType="{x:Type local:CollapsiblePanel}">
<Setter Property="Template">
<Setter.Value>
@ -177,6 +181,8 @@ @@ -177,6 +181,8 @@
</Setter>
</Style>
<!-- Template for RadioButtonGroup -->
<!-- Necessary because Selector does not have a template by default. -->
<Style TargetType="{x:Type local:RadioButtonGroup}">
<Setter Property="Template">
<Setter.Value>
@ -199,4 +205,25 @@ @@ -199,4 +205,25 @@
</Setter.Value>
</Setter>
</Style>
<!-- SortableGridViewColumn.
Displays an up arrow or down arrow in the column header when the grid is sorted using that column.
-->
<local:ColumnSortDirectionToVisibilityConverter x:Key="ColumnSortDirectionToVisibilityConverter"/>
<DataTemplate x:Key="{ComponentResourceKey {x:Type local:SortableGridViewColumn}, ColumnHeaderTemplate}">
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
<Path x:Name="upArrow"
Visibility="{Binding Path=Column.SortDirection, ConverterParameter={x:Static local:ColumnSortDirection.Ascending}, RelativeSource={RelativeSource AncestorType={x:Type GridViewColumnHeader}}, Converter={StaticResource ColumnSortDirectionToVisibilityConverter}}"
StrokeThickness = "1"
Fill = "Gray"
Data = "M 5,10 L 15,10 L 10,5 L 5,10"/>
<Path x:Name="downArrow"
Visibility="{Binding Path=Column.SortDirection, ConverterParameter={x:Static local:ColumnSortDirection.Descending}, RelativeSource={RelativeSource AncestorType={x:Type GridViewColumnHeader}}, Converter={StaticResource ColumnSortDirectionToVisibilityConverter}}"
StrokeThickness = "1"
Fill = "Gray"
Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
</StackPanel>
</DataTemplate>
</ResourceDictionary>
Loading…
Cancel
Save