C# 可编辑的 WPF GridView 行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/234929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Editable WPF GridView Row
提问by Joseph Sturtevant
I am trying to create a databound WPF GridView whose rows can either be read-only or editable (by double-clicking or through a context menu). I would like for the row to return to a read-only state if any of its editable controls loses focus. The functionality I am looking for is very similar to this examplebut with an entire row being editted simultaneously (rather than a single cell). Does anyone know how to implement this?
我正在尝试创建一个数据绑定 WPF GridView,其行可以是只读的或可编辑的(通过双击或通过上下文菜单)。如果任何可编辑控件失去焦点,我希望该行返回只读状态。我正在寻找的功能与此示例非常相似,但同时编辑整行(而不是单个单元格)。有谁知道如何实现这一点?
采纳答案by ema
With the ListView + GridView control il quite complex because this control "thinks in column" so you have to create a template for every column and switch the read-only template with edit template (for every cell). I suggest you to take a look a the xceed DataGrid. It's free and it implements the edit functionality in a simpler way (you can find info here: http://xceed.com/Grid_WPF_Intro.html)
使用 ListView + GridView 控件非常复杂,因为该控件“在列中思考”,因此您必须为每一列创建一个模板,并使用编辑模板(针对每个单元格)切换只读模板。我建议你看看 xceed DataGrid。它是免费的,并且以更简单的方式实现了编辑功能(您可以在此处找到信息:http: //xceed.com/Grid_WPF_Intro.html)
回答by Joachim Kerschbaumer
there is also the "official" wpf datagrid from microsoft at codeplex : http://www.codeplex.com/wpf
还有来自微软在 codeplex 的“官方”wpf 数据网格:http: //www.codeplex.com/wpf
回答by Joy George Kunjikkuru
The latest WPF has its own DataGrid. http://wpftutorial.net/DataGrid.html
最新的 WPF 有自己的 DataGrid。 http://wpftutorial.net/DataGrid.html