Click here to Skip to main content
15,897,891 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Control to display Html in a string - not WebBrowser control Pin
_Maxxx_27-Jan-11 16:49
professional_Maxxx_27-Jan-11 16:49 
GeneralRe: Control to display Html in a string - not WebBrowser control Pin
devvvy27-Jan-11 21:38
devvvy27-Jan-11 21:38 
AnswerRe: Control to display Html in a string - not WebBrowser control Pin
Abhinav S28-Jan-11 2:17
Abhinav S28-Jan-11 2:17 
QuestionTDD - Messenger, Testing Help Request... Pin
_Maxxx_27-Jan-11 15:27
professional_Maxxx_27-Jan-11 15:27 
AnswerRe: TDD - Messenger, Testing Help Request... Pin
Pete O'Hanlon27-Jan-11 22:41
mvePete O'Hanlon27-Jan-11 22:41 
GeneralRe: TDD - Messenger, Testing Help Request... Pin
_Maxxx_30-Jan-11 22:27
professional_Maxxx_30-Jan-11 22:27 
GeneralRe: TDD - Messenger, Testing Help Request... Pin
Pete O'Hanlon31-Jan-11 10:41
mvePete O'Hanlon31-Jan-11 10:41 
QuestionHow to sort list view by clicking column header? [modified] Pin
Tesic Goran27-Jan-11 1:02
professionalTesic Goran27-Jan-11 1:02 
Hello,

I'm new in sorting and not sure how to write the sorting code in order to sort list view by clicking column headers.

I have list view with several columns in my WPF application.
I want to sort list view by clicking any column header.
The list view is populated with data from database using data binding in this way:

List<TestName> lstTestNames = client.GetAllTestNames().ToList();
lstvTestNames.ItemsSource = null;
lstvTestNames.ItemsSource = lstTestNames;


The columns are as usual, ID, string data, date/time date and so on.

The XAML code looks as follows:

<ListView Name="lstvTestNames" Height="360" HorizontalAlignment="Left" Margin="20,33,0,0" VerticalAlignment="Top" Width="465" SelectionChanged="lstvTestNames_SelectionChanged">
  <ListView.View>
    <GridView>
      <GridViewColumn Width="50" DisplayMemberBinding="{Binding Path=test_name_id}">
        <GridViewColumnHeader Name="Sort1" Click="GridViewColumnHeader_Click">ID</GridViewColumnHeader>
      </GridViewColumn>
...


The sorting code should be in click handler:

private void GridViewColumnHeader_Click(object sender, RoutedEventArgs e)
{
  GridViewColumnHeader column = sender as GridViewColumnHeader;

  ...
}


But, how does it look like?

One additional question. If I want to sort list view by ID column that contains IDs from database,
I suppose all those values are strings (maybe not?).
But, I need integer values. How to handle this?


Thank you in advance.

Goran

modified on Thursday, January 27, 2011 7:38 AM

AnswerRe: How to sort list view by clicking column header? Pin
Richard MacCutchan27-Jan-11 2:00
mveRichard MacCutchan27-Jan-11 2:00 
GeneralRe: How to sort list view by clicking column header? Pin
Tesic Goran27-Jan-11 2:32
professionalTesic Goran27-Jan-11 2:32 
GeneralRe: How to sort list view by clicking column header? Pin
Richard MacCutchan27-Jan-11 3:10
mveRichard MacCutchan27-Jan-11 3:10 
GeneralRe: How to sort list view by clicking column header? Pin
Tesic Goran27-Jan-11 3:41
professionalTesic Goran27-Jan-11 3:41 
GeneralRe: How to sort list view by clicking column header? Pin
Richard MacCutchan27-Jan-11 3:55
mveRichard MacCutchan27-Jan-11 3:55 
AnswerRe: How to sort list view by clicking column header? Pin
dasblinkenlight27-Jan-11 3:57
dasblinkenlight27-Jan-11 3:57 
AnswerRe: How to sort list view by clicking column header? Pin
beeritger27-Jan-11 14:10
beeritger27-Jan-11 14:10 
GeneralRe: How to sort list view by clicking column header? Pin
Tesic Goran27-Jan-11 21:19
professionalTesic Goran27-Jan-11 21:19 
Questionpdf to xaml wrapper Pin
BoySetsFire26-Jan-11 3:45
BoySetsFire26-Jan-11 3:45 
AnswerRe: pdf to xaml wrapper Pin
Jason McBurney27-Jan-11 7:32
Jason McBurney27-Jan-11 7:32 
QuestionSilverlight DataGrid throwing error Pin
Santhosh Sebastian Mattathil24-Jan-11 21:48
Santhosh Sebastian Mattathil24-Jan-11 21:48 
AnswerRe: Silverlight DataGrid throwing error Pin
Pete O'Hanlon24-Jan-11 21:55
mvePete O'Hanlon24-Jan-11 21:55 
GeneralRe: Silverlight DataGrid throwing error Pin
Santhosh Sebastian Mattathil24-Jan-11 22:01
Santhosh Sebastian Mattathil24-Jan-11 22:01 
GeneralRe: Silverlight DataGrid throwing error Pin
Pete O'Hanlon24-Jan-11 22:09
mvePete O'Hanlon24-Jan-11 22:09 
GeneralRe: Silverlight DataGrid throwing error Pin
Santhosh Sebastian Mattathil24-Jan-11 22:12
Santhosh Sebastian Mattathil24-Jan-11 22:12 
GeneralRe: Silverlight DataGrid throwing error Pin
Pete O'Hanlon24-Jan-11 23:46
mvePete O'Hanlon24-Jan-11 23:46 
AnswerRe: Silverlight DataGrid throwing error Pin
Abhinav S25-Jan-11 18:27
Abhinav S25-Jan-11 18:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.