.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to detect listview column header clicked from my viewmodel.cs?

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :WPF

i want to sort the listview items when the header of the column is clicked. how do i detect the header click event from my viewmodel class.

i don't want to do this in my xaml code behind.



1 + 1 = 3

View Complete Post

More Related Resource Links

How to expand the listview column header automatically when text grows?


I have a column goes like this:

 <ListView Name="Col1" Margin="5,0" 
     ItemsSource="{Binding Col1}" 
     SelectedValue="{Binding Col1Item, Mode=TwoWay}"
     Width="100" HorizontalAlignment="Left">
        <GridViewColumn Header="{Binding Col1Header}" DisplayMemberBinding="{Binding Name}" />

data of all the items are bound from viewmodel.cs during runtime. i got a problem where the width of header is not adjusted automatically when i got a longer text for it.

what have i missed? please help.


1 + 1 = 3

listView Sort for a celltmplate column

hi , i have a list view with a column that is binded to a field in my database the field contains integers that represents the City_ID , and i a have another table that contains the cities and their ID's, so , when i apply the sort based on this column (City Column) the list View is sorted based on the integers not on the city names here is my XAML definition of that column : GridViewColumn Header="City_Name_ID" Width="75">                         <GridViewColumn.CellTemplate>                             <DataTemplate>                                 <ComboBox IsSynchronizedWithCurrentItem="False" ItemsSource="{Binding Source={StaticResource CitysViewSource}}" SelectedValue="{Binding Path=City_Name_ID}" SelectedValuePath="City_ID" DisplayMemberPath="City_Name"/>                      &nb

How to scroll the DataGrid (horizontally) when user drags a column header far left or right?

We're working with the WPF DataGrid and I have a question about  dragging column headers: The grid lets the user rearrange the columns, by dragging the column header left or right.  So far, so good. But, sometimes we have many columns, and only the first few columns are visible; so there is a horizontal scrollbar.  In such case, if the user drags a column header to the right edge of the DataGrid window, I want the DataGrid to scroll, automatically, one column at a time.  Is there an easy way to do that? (To be clear: yes, the user can already scroll horizontally by interacting with the horizontal scrollbar, but that isn't what I'm asking about.  I'm asking if the "drag a column header left or right" gesture can cause the DataGrid to scroll left or right.) I guess I could handle various low-level events, but it seems like it shouldn't be necessary -- DataGrid has so much functionality built-in, that I'm guessing it already has the ability to scroll when the user drags the column header to the edge.  So, is there either (a) a property that I can set, to tell the DataGrid to scroll when the user drags a column header to the edge of the window;  or (b) a code example showing how to achieve this effect myself?  Thanks!

SSRS 2008 - repeating a non column header column on every page

Hi - I am working on my first SSRS report and I have mostly all of it down except one issue. Per requirements, I need to display a column that is a non header column to repeat on every page while printing and or when I save the generated report in SSRS as a PDF file. I have seen some previous blog from 2007 where RepeatWith property is recommended to be set to the same name of the Tablix in which the column(s) are embeded, tried that but it is not working. Can any one help me on this or guide me how to resolve this? Thanks, Manny

Alignment of GridViewColumn Header in ListView

I must be missing something really obvious here, but how do I align the content of the header of a GridViewColumn in a ListView?   I tired applying a DataTemplate for the header like so:   <GridViewColumn Header="MyHeader" Width="80" DisplayMemberBinding="{Binding TrDt}">    <GridViewColumn.HeaderTemplate>       <DataTemplate>          <TextBlock Text="{Binding}" HorizontalAlignment="Left"/>       </DataTemplate>    </GridViewColumn.HeaderTemplate> </GridViewColumn>   But the header still comes out center aligned... Any hints?

3 Column Listview output - is it possible

hi all, i am looking to create a 3 column listview output that looks like this.  Basically its an alphabetic list of one field but it needs to output like newspaper columns.  Is it possible to do this with simply css?  Or will i have to programmaticaly break up the dataset into 3 and actually make 3 listviews?     aaaaaaabaaacaaadaaaeaaaf   aaagaaahaaaiaaajaaalaaam aaanaaaoaaapaaaqaaar

ListView fixed size column headers

Hi, I am using a ListView in its 'Detail' view. I have added several columns there and I want to restrict resizing the column width. I couldn't find a ways to do that; is there any easy way to do that? ThanksCJ

Remove Empty Listview Header

Can any one help me to remove the empty header generated at the end of a listview . i am using it to display a gridview of rows.

Listview column issue??

Hello.      i have a listview with around 9 column and in that i have column as Address.Now everything works fine....Now suppose lots of character in Address then my css breaks...Is it possible to display few characters of the address followed by .....  ??? i have seen in few site but no clue how to implement...like instead of          Abhishek,House No.30,Middle Lane,Arizon.i want just        Abhishek,House No.30,Middle ......and i would like to implemet mouse hover extender later to display full address but i am not able to implement first part only...Can any one guide me on this??? and i have used this link for my css. http://mattberseth.com/blog/2008/05/modifying_data_with_the_listvi.htmlThanks.

Data template for Icon in Header of listview on sorting

I have 2 datatemplates that show 2 icons for sorting on ascending and on descending.. <DataTemplate x:Uid="HeaderTemplateArrowDown"> <DockPanel> <TextBlock Text="{Binding}"/> <Path x:Name="arrow" StrokeThickness = "1" Fill = "gray" Data = "M 5,10 L 15,10 L 10,5 L 5,10"/> </DockPanel> </DataTemplate> <DataTemplate x:Uid="HeaderTemplateArrowUp"> <DockPanel> <TextBlock Text="{Binding }"/> <Path x:Name="arrow" StrokeThickness = "1" Fill = "gray" Data = "M 5,5 L 10,10 L 15,5 L 5,5"/> </DockPanel> </DataTemplate> So now how do i use these in my theme file . How do i use them at a time all over my project in multiple forms from my theme file. Like how do i include these datatemplates into the GridViewColumnHeader Style.

Is it possible to hide column header in list view webparts?


I can't seem to find a way to hide the column header of a list view web part.  Is it possible?  It appears that OOB the only list that doesn't show the column header in web parts is the Link List.


sharepoint column Header multiline


Hello Every one,

I am new to SharePoint.

I am using a Issue Tracking List in Sharepoint, and i have lenghthier column header and a small column data.  Is there any simple way of making the column header multiline.

Please let me know hyour suggestions


How to revert the column header sorting in DataGridView



I want to get the old state (lets say datagridview default state) of grid after sorting is done. How can I achive this.

Please suggest.

Please remember to click 'Mark as Answer' on the post that helped you.

How to Use Same Header Name for Multiple Column in GridView ?



Hi All ,

         This is my  Needed view ,


                           Report1                 |                          Report2                         | - Main Header


SEL1    |  SEL2    | SEL3   |     SEL4   |       SEL1    |  SEL2    | SEL3   |     SEL4   |   - Sub Header



But afte

Remove column from Listview


I'm binding a listview control to LinqDataSource and can't find a way to remove unnecessary columns.

remove Column header from List View Webpart


hi, i am having sharepoint 2010 Enterprise RTM trial on Windows server 2008 SP2. I wanted to know how a column header of a list in List View Webpart can be hide ?

i have tried the following article:


but i don't see any source editor in content Editor Weppart and also the Hidden button is disabled....

Is it necessary to do this task from code ?

document library column header is missing


When I open any document libraries within a specified site collection, I found out they all missing column headers. I could not do sorting on the columns. Anyone knows why?

Thanks in advance,



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend