问题描述
你好,
我有一个包含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
推荐答案
<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问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!