WPF Listview出现问题 [英] probleme with WPF Listview

查看:84
本文介绍了WPF Listview出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我对列表视图列标题有疑问,
问题:

1-我要固定标题宽度并停止调整列的大小,
所以我确实开设了一堂课.这是代码:

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);

}

}



这是我在xmal代码中使用它时的类,它的工作宽度是固定的,不能更改cloumn的大小,
问题是我要向她添加一个处理程序,她的错误出现
这是我在Xaml代码中写的:



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>




错误是FixedWidthColumn不包含AddHAndler的定义.

我如何定义添加处理程序?
以及当鼠标悬停在标题上方时,如何更改光标样式?

这是我的问题,感谢您对我的热情,我希望任何人都可以帮助我解决这个问题.




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

推荐答案

我不明白您为什么要做您自己的客户GridViewColumn.如果将标准列的宽度设置为固定值,则它不会自动调整大小.
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.


但是用户可以在列表视图标题上方拖动鼠标以调整其大小以停止这个动作我确实做了我自己的GridViewColumn
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


这篇关于WPF Listview出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆