编辑datagridcell时出现DataGrid问题 [英] DataGrid problem while editing the datagridcell

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

问题描述

你好,

我有一个包含Silverlight DataGrid的xaml文件.如您所知,在Silverlight Datagrid中,每当该用户开始编辑一行(一行)时,就会自动调用beginEdit,然后在他完成编辑时调用EndEdit. >
但这对具有dataTemplate的datagrid列根本不起作用,例如:

Hello,

I have a xaml file that contains a silverlight DataGrid. As you know, that in a silverlight Datagrid, whenever that user starts editing a line (a row) the beginEdit is called automatically, and then when he finishes editing EndEdit is called... This works fine with DataGridTextColumn and DataGridCheckBoxColumns.

But it doesn''t work at all with datagrid columns that have a dataTemplate, for example:

<DatagridTemplateColumn>

<DataGridTemplateColumn.CellTemplate>

<DataTemplate>

<TextBox  Text={Binding Path=Model.Name, Mode=TwoWay} >

</DataTemplate>

</DataGridTemplateColumn.CellTemplate>

</DatagridTemplateColumn>


在上面的列中,如果更改了在文本框中找到的值,然后按Enter,则不会将BeginEdit和EndEdit称为....

我上面的列模板很简单,我知道我可以用DataGridTextColumn替换它,但是实际上我正在使用TemplateColumns作为组合框...

谢谢


In the above column, if a change the value found in the textbox and then press enter, the BeginEdit and EndEdit are not called...

My above column template is easy, I know that I can replace it by DataGridTextColumn, but actually I''m using TemplateColumns for comboboxes ...

Thanks

推荐答案

您可能应该添加:
YOu probably should add :
<datagridtemplatecolumn.>CellEditingTemplate>

<DataTemplate>

<TextBox  Text={Binding Path=Model.Name, Mode=TwoWay} >

</DataTemplate>

</DataGridTemplateColumn.CellEditingTemplate></datagridtemplatecolumn.>




P.S
DataGridTemplateColumn.CellTemplate应该包含TextBlock




P.S
the DataGridTemplateColumn.CellTemplate should contain TextBlock


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

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