Using system;
Using system. componentmodel;
Using system. Collections. Generic;
Using system. diagnostics;
Using system. text;
Using devexpress. expressapp;
Using devexpress. expressapp. actions;
Using devexpress. Persistent. base;
Using devexpress. expressapp. model;
Using devexpress. expressapp. Win. systemmodule;
Namespace xafextendtest. Module. systemmodule
{
Public interface imodelclassautocommitlistview: imodelnode
{
[Category ("mycustomproperty")]
[Description ("control if change on editable listview will be autocommited")]
Bool autocommitlistview {Get; set ;}
}
[Modelinterfaceimplementor (typeof (imodelclassautocommitlistview), "modelclass")]
Public interface imodellistviewautocommitlistview: imodelclassautocommitlistview
{
}
Public class autocommitlistviewcontroller: viewcontroller <listview>, imodelextender
{
Protected override void onviewcontrollersactivated ()
{
Base. onactivated ();
VaR windetailviewcontroller = frame. getcontroller <windetailviewcontroller> ();
If (windetailviewcontroller! = NULL & (imodellistviewautocommitlistview) view. Model). autocommitlistview)
{
Windetailviewcontroller. autocommitlistview = true;
View. querycanchangecurrentobject + = view_querycanchangecurrentobject;
}
}
Void view_querycanchangecurrentobject (Object sender, canceleventargs E)
{
If (frame. getcontroller <windetailviewcontroller> (). suppressconfirmation)
Objectspace. commitchanges ();
}
Protected override void ondeactivated ()
{
Base. ondeactivated ();
VaR windetailviewcontroller = frame. getcontroller <windetailviewcontroller> ();
If (windetailviewcontroller! = NULL & (imodellistviewautocommitlistview) view. Model). autocommitlistview)
{
Windetailviewcontroller. autocommitlistview = true;
View. querycanchangecurrentobject-= view_querycanchangecurrentobject;
}
}
Void imodelextender. extendmodelinterfaces (modelinterfaceextenders extenders)
{
Extenders. Add <imodelclass, imodelclassautocommitlistview> ();
Extenders. Add <imodellistview, imodellistviewautocommitlistview> ();
}
}
}
Welcome to reprint, reprint please indicate the source: http://www.cnblogs.com/Tonyyang/