wpf的listview编辑指定列_wpf – 如何在ListView中使列可编辑?

这篇博客介绍了如何创建一个名为EditBox的自定义控件,它在GridViewColumn中作为CellTemplate使用。在常态下TextBlock展示内容,编辑时切换至TextBox进行编辑。文章详细讲解了依赖属性设置和样式的定制。
摘要由CSDN通过智能技术生成

为GridViewColumn.CellTemplate创建一个名为EditBox的自定义控件.

在普通模式下,TextBlock用于显示内容;

在编辑模式下,将弹出一个TextBox进行编辑.

从Control控制的类

public class EditBox : Control

{

static EditBox()

{

public static readonly DependencyProperty ValueProperty =

DependencyProperty.Register(

"Value",

typeof(object),

typeof(EditBox),

new FrameworkPropertyMetadata());

}

为IsEditing添加依赖项属性.

public static DependencyProperty IsEditingProperty =

DependencyProperty.Register(

"IsEditing",

typeof(bool),

typeof(EditBox),

new FrameworkPropertyMetadata(false)

);

自定义EditBox的样式:

Text="{Binding Path=Value, RelativeSource = {RelativeSource TemplatedParent}}">

在您的Xaml中,您可以放置​​EditBox:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值