关于Silverlight DataGrid控件 [英] About Silverlight DataGrid Control

查看:82
本文介绍了关于Silverlight DataGrid控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在DataGrid的RowEditEnded事件发生时保存实体,如下所示:

I want to save entity when DataGrid''s RowEditEnded event happen,like this:

Grid.RowEditEnded += (s, e) =><br />
    {<br />
        if (e.EditAction == DataGridEditAction.Commit)<br />
        {<br />
            //DoSave();<br />
        }<br />
    };



但是当DataGrid Control失去焦点时,RowEditEnded事件发生了.EditAction = DataGridEditAction.Commit。

在这种情况下,我不想做任何事情。

我该怎么办?当e.EditAction = DataGridEditAction.Cancle在上面的例子中?


But the RowEditEnded event happen when DataGrid Control lost focus and e.EditAction=DataGridEditAction.Commit.
In this case,I don''t want to do anything.
What should I do ? When e.EditAction=DataGridEditAction.Cancle in the above example?

推荐答案

我的解决方案:

当DataGrid的SelectedChanged事件时保存实体发生,像这样:

My solution:
Save entity when DataGrid''s SelectedChanged event happen, like this:
<br />
    Grid.SelectedChanged+=(s,e)=><br />
    {<br />
        //DoSave();<br />
    };<br />



要实体save是当前DataGrid的SelectItem,但是当SelectedChanged事件发生时它已经改变了,所以我必须做另一件事以确保保存实体是Grid的前一个SelectItem。


The entity to be save is current DataGrid''s SelectItem,but it have already changed when SelectedChanged event happend,so I have to do anther thing to insure the to save entity is the previous SelectItem of Grid.


这篇关于关于Silverlight DataGrid控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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