Click here to Skip to main content
14,735,206 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem with the list view column header,
the problem :

1-I want to fix the header width and stop column resizing,
so i did implement a class . this is the code:

public class FixedWidthColumn : GridViewColumn

static FixedWidthColumn()
new FrameworkPropertyMetadata(null,new CoerceValueCallBack(OnCoerceWidth)));


private static object OnCoerceWidth(DependencyObject o,object baseValue)
FixedWidthColumn fws = o as FixedWidthColumn;
if(fws != null) 
return fws.FixedWidth;

return baseValue;

public double FixedWidth
get{return (double)GetValue(FixedWidthProperty);}


public static readonly DependencyProperty FixedWidthProperty=
new FrameworkPropertyMetadata(double.NaN,new PropertyChangedCallBack(OnFixedWidthChanged))

private static void OnFixedWidthChanged(DependencyObject o,DependencyPropertyChangedEventArgs e)
FixedWidthColumn fws=o as FixedColumn;
if(fes != null)



this is the class when i use it in the xmal code it work the width is fixed and can not change the cloumn size ,
the problem is i want to add a Handler m her the error appear
this what i did write in the Xaml code:


<customgridheader:fixedwidthcolumn fixedwidth="110" header="Test1" mouse.mouseup="OnTestClick" xmlns:customgridheader="#unknown" />

the error is FixedWidthColumn does not contain definition for AddHAndler.

How can i definie the add handler???
and how can i change the cursor style when the mouse is over the header ??

this my problem , thx for your passion on me and i hope that any one can help me in this problem
Updated 26-Jan-12 0:10am

I don't understand why you had to make your own customer GridViewColumn. If you set the width on the standard column to a fixed amount, then it does not resize itself.
but the user can resize it on dragind the mouse over the list view header,to stop this action i did make my own GridViewColumn

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900