防止用户使用 WPF ListView 调整列大小 [英] Prevent user from resizing columns with WPF ListView

查看:35
本文介绍了防止用户使用 WPF ListView 调整列大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止用户使用 ListView 控件调整 GridViewColumns 的大小?

How can I prevent a user from resizing GridViewColumns withing a ListView control?

推荐答案

我找到了一个解决方案,可能有一天它会帮助其他人;)

i found a solution and probably it will help someone else someday ;)

您必须覆盖 GridViewColumnHeader 的 ControlTemplate(默认模板是 此处) 并从模板中删除 PART_HeaderGripper 以防止调整列的大小.

you have to override the GridViewColumnHeader's ControlTemplate (default template is here ) and remove the PART_HeaderGripper from the template in order to prevent resizing of your columns.

还有另一种解决方案,它在 here 中描述了子类化 GridViewColumn.出于表示目的,我更喜欢仅 xaml 的解决方案

there is another solution that comes up with subclassing GridViewColumn described here. for representation purposes i prefer xaml only solutions though

这篇关于防止用户使用 WPF ListView 调整列大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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