Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
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:

C#
public class FixedWidthColumn : GridViewColumn
{

static FixedWidthColumn()
{
widthProperty.OvverideMetadata(typeof(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);}
set{SetValue(FixedWidthProperty,value);}

}


public static readonly DependencyProperty FixedWidthProperty=
DependencyProperty.Register
("FixedWidth",
typeof(double),
typeof(FixedWidthColumn),
new FrameworkPropertyMetadata(double.NaN,new PropertyChangedCallBack(OnFixedWidthChanged))
);

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

}

}


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:

HTML
<listview.view>
<gridview>

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



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
Posted
Updated 25-Jan-12 23:10pm
v2

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.
 
Share this answer
 
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
 
Share this answer
 

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