WPF:GridViewColumn 调整大小事件
我将 ListView
与 GridView
一起使用。是否有 GridViewColumn 调整大小事件?
I'm using ListView
with GridView
. Is there GridViewColumn
resize event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我将改为处理
PropertyChanged
事件。 Visual Studio 智能感知中看不到PropertyChanged
事件,但您可以欺骗它:)I will handle the
PropertyChanged
event instead. ThePropertyChanged
event is not seen in the Visual Studio intellisense, but you can trick it :)尽管
GridViewColumn
似乎没有Resize
事件,但您可以绑定到ColumnWidth
属性。您可以使用下面的示例 XAML 来验证这一点 - 此示例不需要隐藏代码。它仅在一个方向上绑定,从列宽到文本框,当您调整大小时,您将看到文本框立即随列宽更新。
(这只是一个简单的示例;如果您想在代码中获取调整大小,我将创建一个具有
Width
属性的类,以便绑定可以在两个方向上工作)。Although
GridViewColumn
does not appear to have aResize
event, you can bind to theColumnWidth
property.You can verify this with sample XAML below - no code behind needed for this example. It binds only in one direction, from the column width to the text box, and when you resize you will see the textbox immediately update with the column width.
(This is just a simple example; if you want to pick up the resize in code I would create a class with a
Width
property so binding will work in both directions).查看MSDN DridViewColumn 详细信息. 似乎没有这样的事件,可能需要一些解决方法,但我不确定。 看这里
希望它有所帮助。
Have a look at MSDN DridViewColumn details. It does not appaer to have such an event, probably some workaround required, I am not sure though. have look here
Hope it helps.
XAML:
XAML:
另一种方法:您可以将更改事件处理程序附加到 GridViewColumn
Width
属性:(受答案启发 此处,有关 DataGrid 的类似问题。)
Another approach: you can attach a change event handler to the GridViewColumn
Width
property:(Inspired by an answer here, for a similar question about DataGrid.)