ColumnSortBehavior ClassDW.WPFToolkit Documentation
Brings the feature to UI elements with a GridViewColumnHeader to have a sorting by clicking the corresponding header.
Inheritance Hierarchy

SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      DW.WPFToolkit.InteractivityColumnSortBehavior

Namespace: DW.WPFToolkit.Interactivity
Assembly: DW.WPFToolkit (in DW.WPFToolkit.dll) Version: 5.6.0.0
Syntax

C#
public class ColumnSortBehavior : DependencyObject

The ColumnSortBehavior type exposes the following members.

Constructors

  NameDescription
Public methodColumnSortBehavior
Initializes a new instance of the ColumnSortBehavior class
Top
Methods

  NameDescription
Public methodStatic memberGetAllowColumnSortings
Gets the value that indicates if sorting is allowed or not.
Public methodStatic memberGetAscendingSortHeaderTemplate
Gets the header template to be used for sorting if the column is used for sort ascending actually.
Public methodStatic memberGetDescendingSortHeaderTemplate
Gets the header template to be used for sorting if the column is used for sort descending actually.
Public methodStatic memberGetIsDefaultSortColumn
Gets a value that indicates if a column is defined as default sort column or not.
Public methodStatic memberGetNeutralHeaderTemplate
Gets the header template to be used for sorting if the column is not used for sort actually.
Public methodStatic memberGetSortPropertyName
Gets the property name to be used for sorting.
Public methodStatic memberSetAllowColumnSortings
Attaches the value if sorting is allowed or not.
Public methodStatic memberSetAscendingSortHeaderTemplate
Attaches the header template to be used for sorting if the column is used for sort ascending actually.
Public methodStatic memberSetDescendingSortHeaderTemplate
Attaches the header template to be used for sorting if the column is used for sort descending actually.
Public methodStatic memberSetIsDefaultSortColumn
Attaches a value that indicates if a column is defined as default sort column or not.
Public methodStatic memberSetNeutralHeaderTemplate
Attaches the header template to be used for sorting if the column is not used for sort actually.
Public methodStatic memberSetSortPropertyName
Attaches the property name to be used for sorting.
Top
Fields

  NameDescription
Public fieldStatic memberAllowColumnSortingsProperty
Public fieldStatic memberAscendingSortHeaderTemplateProperty
Public fieldStatic memberDescendingSortHeaderTemplateProperty
Public fieldStatic memberIsDefaultSortColumnProperty
Public fieldStatic memberNeutralHeaderTemplateProperty
Public fieldStatic memberSortPropertyNameProperty
Top
Attached Properties

  NameDescription
Public attached propertyAllowColumnSortings
Public attached propertyAscendingSortHeaderTemplate
Public attached propertyDescendingSortHeaderTemplate
Public attached propertyIsDefaultSortColumn
Public attached propertyNeutralHeaderTemplate
Public attached propertySortPropertyName
Top
Examples

XAML
<DataTemplate x:Key="HeaderArrowUp">
    <Grid>
        <TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center" />
        <Path StrokeThickness="0" SnapsToDevicePixels="True" Data="M 0,4 L 4,0 L 8,4 L 0,4"
              Margin="0,-2,0,0" VerticalAlignment="Top" HorizontalAlignment="Center">
            <Path.Fill>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Color="#FF3C5E72" Offset="0"/>
                    <GradientStop Color="#FFC3E4F5" Offset="1"/>
                </LinearGradientBrush>
            </Path.Fill>
        </Path>
    </Grid>
</DataTemplate>
<DataTemplate x:Key="HeaderArrowDown">
    <Grid>
        <TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center" />
        <Path StrokeThickness="0" SnapsToDevicePixels="True" Data="M 0,0 L 4,4 L 8,0 L 0,0"
              Margin="0,-2,0,0" VerticalAlignment="Top" HorizontalAlignment="Center">
            <Path.Fill>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Color="#FF3C5E72" Offset="0"/>
                    <GradientStop Color="#FFC4E3F4" Offset="1"/>
                </LinearGradientBrush>
            </Path.Fill>
        </Path>
    </Grid>
</DataTemplate>
<DataTemplate x:Key="HeaderTransparent">
    <Grid>
        <TextBlock Text="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Center" />
    </Grid>
</DataTemplate>

<ListView Interactivity:ColumnSortBehavior.AllowColumnSortings="True"
          Interactivity:ColumnSortBehavior.AscendingSortHeaderTemplate="{StaticResource HeaderArrowUp}"
          Interactivity:ColumnSortBehavior.DescendingSortHeaderTemplate="{StaticResource HeaderArrowDown}"
          Interactivity:ColumnSortBehavior.NeutralHeaderTemplate="{StaticResource HeaderTransparent}">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Name" Interactivity:ColumnSortBehavior.IsDefaultSortColumn="True" Interactivity:ColumnSortBehavior.SortPropertyName="Name" />
            <GridViewColumn Header="Size" Interactivity:ColumnSortBehavior.SortPropertyName="Size" />
            <GridViewColumn Header="Date" Interactivity:ColumnSortBehavior.SortPropertyName="Date" />
        </GridView>
    </ListView.View>
</ListView>
See Also

Reference