Click here to Skip to main content
14,669,375 members
Rate this:
Please Sign up or sign in to vote.
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:

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:

<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

Rate this:
Please Sign up or sign in to vote.

Solution 2

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
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100