Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:19:50+00:00 2026-05-29T10:19:50+00:00

I have 7 different ListViews. There is a Sortmethod called SortClick(object sender, RoutedEventArgs e)

  • 0

I have 7 different ListViews.

There is a Sortmethod called SortClick(object sender, RoutedEventArgs e) –
when clicking on a GridViewColumnHeader, it raises the SortClick Event.

But in this method I must tell, which ListView should be Sorted, b.e

listview2.SortNow();

Now my Question is, how can I get the Control (ListView) from the GridViewColumnHeader (sender) or maybe the e, is that even possible?

How the ListView XAML looks like:

<ListView ItemsSource="{Binding MissingTables}" Name="missingTablesListView" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0" MinHeight="540" HorizontalContentAlignment="Stretch">
                    <ListView.Background>
                        <ImageBrush />
                    </ListView.Background>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn DisplayMemberBinding="{Binding TableName}" Width="Auto">
                                <GridViewColumnHeader Click="SortClick" Content="TableName" Tag="TableName" ToolTip="Sortieren" />
                            </GridViewColumn>   
                            <GridViewColumn DisplayMemberBinding="{Binding Beschreibung}" Width="Auto">
                                <GridViewColumnHeader Click="SortClick" Content="Description" Tag="Beschreibung" ToolTip="Sortieren" />
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>

Here is the SortClick Code:

        /// <summary>
        /// Sortiert (Ascending/Descending)
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void SortClick(object sender, RoutedEventArgs e)
        {       
            //ListView listView = sender as ListView;

            GridViewColumnHeader column = sender as GridViewColumnHeader;
            String field = column.Tag as String;

            if (currentSortColumn != null)
            {
                AdornerLayer.GetAdornerLayer(currentSortColumn).Remove(sorter);
                listView.Items.SortDescriptions.Clear();
            }

            ListSortDirection newDir = ListSortDirection.Ascending;
            if (currentSortColumn == column && sorter.Direction == newDir)
            {
                newDir = ListSortDirection.Descending;
            }

            currentSortColumn = column;
            sorter = new Sorter(currentSortColumn, newDir);
            AdornerLayer.GetAdornerLayer(currentSortColumn).Add(sorter);
            listView.Items.SortDescriptions.Add(new SortDescription(field, newDir));
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:19:51+00:00Added an answer on May 29, 2026 at 10:19 am

    I’m not quite sure what you mean when you say SortClick Event, but i guess you mean the GridViewColumnHeader.Click event with your SortClick handler attached.

    If you add the GridViewColumnHeader.Click to the ListViews like this:

    <ListView GridViewColumnHeader.Click="SortClick">
    

    you will get the ListView control in the sender argument of your event handler, and the GridViewColumnHeader in e.OriginalSource.

    EDIT for clarity. In your SortClick handler, you’ll access the control like this:

    ListView listView = sender as ListView;
    GridViewColumnHeader header = e.OriginalSource as GridViewColumnHeader;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity with three listviews, each having three different cursors, but all
I have a page with two Listviews (with two different data sources). I have
I have several similar user controls which display listviews of respectively different data entities.
I have a RelativeLayout with different elements. I was planning to have two ListViews
I have a WPF program with two listviews which display information from two different
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have different php output in jQuery-based tabs. This output is formed from database
I have different urls that points to the same code www.url1.com www.url2.com I need
I have different projects written in .NET 3.5 and some unit test projects to
different programming languages have different features or lack certain features. Design patterns are a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.