public static void Initialize(IXpoSessionAwareControl control, IObjectSpace objectSpace) { // The IXpoSessionAwareControl interface is needed to pass a Session into a custom control that is supposed to implement this interface. Guard.ArgumentNotNull(control, "control"); Guard.ArgumentNotNull(objectSpace, "objectSpace"); // If a custom control is XAF-aware, then use the IObjectSpace to query data and bind it to your custom control (http://documentation.devexpress.com/#Xaf/clsDevExpressExpressAppBaseObjectSpacetopic). // See some examples below: //Type persistentDataType = typeof(DevExpress.Persistent.BaseImpl.Task); //IList persistentData = objectSpace.GetObjects(persistentDataType, CriteriaOperator.Parse("Status = 'InProgress'")); // Session is required to query data when a custom control is XPO-aware only. // You can pass an XafApplication into your custom control in a similar manner, if necessary. DevExpress.ExpressApp.Xpo.XPObjectSpace xpObjectSpace = ((DevExpress.ExpressApp.Xpo.XPObjectSpace)objectSpace); control.UpdateDataSource(xpObjectSpace.Session); // It is required to update the session when ObjectSpace is reloaded. objectSpace.Reloaded += delegate(object sender, EventArgs args) { control.UpdateDataSource(xpObjectSpace.Session); }; }
public static void Initialize(IXpoSessionAwareControl sessionAwareControl, XafApplication theApplication) { Initialize(sessionAwareControl, theApplication != null ? theApplication.CreateObjectSpace() : null); }