using System;
using DevExpress.Xpo;
namespace InstantFeedbackMode {
public class TestObject : XPObject {
string _subject;
public string Subject {
get { return _subject; }
set { SetPropertyValue<string>("Subject", ref _subject, value); }
}
DateTime _sent;
public DateTime Sent {
get { return _sent; }
set { SetPropertyValue<DateTime>("Sent", ref _sent, value); }
}
bool _hasAttachment;
public bool HasAttachment {
get { return _hasAttachment; }
set { SetPropertyValue<bool>("HasAttachment", ref _hasAttachment, value); }
}
public TestObject(Session session) : base(session) { }
public TestObject() : base(Session.DefaultSession) { }
public override void AfterConstruction() { base.AfterConstruction(); }
}
}
using System;
using System.Windows;
using DevExpress.Data.Filtering;
using DevExpress.Xpf.Grid;
using DevExpress.Xpo;
using DevExpress.Xpf.Core;
namespace InstantFeedbackMode {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitDAL();
// Generates test data - 100,000 records.
GenerateTestData(100000);
InitializeComponent();
// Creates and initializes the data source which activates the Instant Feedback UI Mode.
XPInstantFeedbackSource instantDS = new XPInstantFeedbackSource(typeof(TestObject));
instantDS.ResolveSession += new EventHandler<ResolveSessionEventArgs>(instantDS_ResolveSession);
instantDS.DismissSession += new EventHandler<ResolveSessionEventArgs>(instantDS_DismissSession);
// Bind the grid.
grid.ItemsSource = instantDS;
}
void instantDS_ResolveSession(object sender, ResolveSessionEventArgs e) {
e.Session = new UnitOfWork();
}
void instantDS_DismissSession(object sender, ResolveSessionEventArgs e) {
IDisposable session = e.Session as IDisposable;
if (session != null) {
session.Dispose();
}
}
private static void InitDAL() {
XpoDefault.Session = null;
XpoDefault.DataLayer = XpoDefault.GetDataLayer(
DevExpress.Xpo.DB.AccessConnectionProvider.GetConnectionString("test.mdb"),
DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema
);
}
private void GenerateTestData(int recordCount) {
using (UnitOfWork s = new UnitOfWork()) {
if (s.FindObject<TestObject>(null) != null) return;
for (int i = 0; i < recordCount; i++) {
TestObject o = new TestObject(s) { HasAttachment = false, Sent = DateTime.Now, Subject = string.Format("Subject {0}", i) };
}
s.CommitChanges();
}
}
}
}
<Window x:Class="InstantFeedbackMode.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core">
<Grid>
<dxg:GridControl Name="grid" AutoGenerateColumns="AddNew" />
</Grid>
</Window>
Imports System
Imports System.Windows
Imports DevExpress.Data.Filtering
Imports DevExpress.Xpf.Grid
Imports DevExpress.Xpo
Imports DevExpress.Xpf.Core
Namespace InstantFeedbackMode
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitDAL()
' Generates test data - 100,000 records.
GenerateTestData(100000)
InitializeComponent()
' Creates and initializes the data source which activates the Instant Feedback UI Mode.
Dim instantDS As New XPInstantFeedbackSource(GetType(TestObject))
AddHandler instantDS.ResolveSession, AddressOf instantDS_ResolveSession
AddHandler instantDS.DismissSession, AddressOf instantDS_DismissSession
' Bind the grid.
grid.ItemsSource = instantDS
End Sub
Private Sub instantDS_ResolveSession(ByVal sender As Object, ByVal e As ResolveSessionEventArgs)
e.Session = New UnitOfWork()
End Sub
Private Sub instantDS_DismissSession(ByVal sender As Object, ByVal e As ResolveSessionEventArgs)
Dim session As IDisposable = TryCast(e.Session, IDisposable)
If session IsNot Nothing Then
session.Dispose()
End If
End Sub
Private Shared Sub InitDAL()
XpoDefault.Session = Nothing
XpoDefault.DataLayer = XpoDefault.GetDataLayer(DevExpress.Xpo.DB.AccessConnectionProvider.GetConnectionString("test.mdb"), DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema)
End Sub
Private Sub GenerateTestData(ByVal recordCount As Integer)
Using s As New UnitOfWork()
If s.FindObject(Of TestObject)(Nothing) IsNot Nothing Then
Return
End If
For i As Integer = 0 To recordCount - 1
Dim o As New TestObject(s) With {.HasAttachment = False, .Sent = Date.Now, .Subject = String.Format("Subject {0}", i)}
Next i
s.CommitChanges()
End Using
End Sub
End Class
End Namespace
Imports System
Imports DevExpress.Xpo
Namespace InstantFeedbackMode
Public Class TestObject
Inherits XPObject
Private _subject As String
Public Property Subject() As String
Get
Return _subject
End Get
Set(ByVal value As String)
SetPropertyValue(Of String)("Subject", _subject, value)
End Set
End Property
Private _sent As Date
Public Property Sent() As Date
Get
Return _sent
End Get
Set(ByVal value As Date)
SetPropertyValue(Of Date)("Sent", _sent, value)
End Set
End Property
Private _hasAttachment As Boolean
Public Property HasAttachment() As Boolean
Get
Return _hasAttachment
End Get
Set(ByVal value As Boolean)
SetPropertyValue(Of Boolean)("HasAttachment", _hasAttachment, value)
End Set
End Property
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public Sub New()
MyBase.New(Session.DefaultSession)
End Sub
Public Overrides Sub AfterConstruction()
MyBase.AfterConstruction()
End Sub
End Class
End Namespace