Skip to main content
A newer version of this page is available. .

RealTimeSource

  • 5 minutes to read

The RealTimeSource component is designed to display small amounts of rapidly changing data while keeping the user interface responsive.

Note

The RealTimeSource can effectively work with data sources with not more then several hundred data records.

The following animation demonstrates a GridControl bound to dynamic data using the RealTimeSource.

WPF RealTimeSource

You should consider using the RealTimeSource component if records in your data source are frequently updated (e.g., 20 000 updates per second).

The use of the RealTimeSource with static data will not result in any performance improvements.

Note

The RealTimeSource is a layer between a data-aware control and the actual data.

Before you decide to use the RealTimeSource component in your application, consider the following limitations.

Initializing the RealTimeSource

You can bind any data-aware control to the RealTimeSource. The GridControl is taken as an example.

To display real-time data in the GridControl, do the following.

ObservableCollection<Data> Persons;
//...
DevExpress.Data.RealTimeSource myRealTimeSource = new DevExpress.Data.RealTimeSource();
myRealTimeSource.DataSource = Persons;
myGridControl.ItemsSource = myRealTimeSource;

The following table describes additional RealTimeSource configuration scenarios.

Scenario

Approach

Specify which data source properties

are passed to a data-aware control.

Specify the required data source properties using the RealTimeSource.DisplayableProperties property.

//A semicolon-separated list of data source property names
myRealTimeSource.DisplayableProperties = "Id;Progress";

Ignore modifications of individual property values.

Set the RealTimeSource.IgnoreItemEvents property to true.

Modifications of data source items will be ignored by the RealTimeSource.

Only modifications made to the data source list will be passed to a data-aware control.

Example

This example demonstrates how to use the RealTimeSource component to display rapidly changing data within the GridControl.

Note

Data in this example is randomly generated for demonstration purposes.

View Example

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Windows
Imports System.Collections.ObjectModel
Imports System.Globalization
Imports System.Windows.Data
Imports System.Windows.Markup
Imports DevExpress.Data
Imports System.Windows.Threading
Imports System.ComponentModel

Namespace RealTimeSourceExample
    Partial Public Class MainWindow
        Inherits Window
        Private Persons As ObservableCollection(Of Data)
        Private Count As Integer = 50
        Private Random As New Random()
        Public Sub New()
            InitializeComponent()
            Persons = New ObservableCollection(Of Data)()
            For i As Integer = 0 To Count - 1
                Persons.Add(New Data With {.Id = i, .Text = "Text" & i, .Progress = GetNumber()})
            Next i

            grid.ItemsSource = New RealTimeSource() With {.DataSource = Persons}

            Dim timer As New DispatcherTimer()
            timer.Interval = TimeSpan.FromMilliseconds(1)
            AddHandler timer.Tick, AddressOf Tick
            timer.Start()
        End Sub

        Private Sub Tick(ByVal sender As Object, ByVal e As EventArgs)
            Dim index As Integer = Random.Next(0, Count)
            Persons(index).Id = GetNumber()
            Persons(index).Text = "Text" & GetNumber()
            Persons(index).Progress = GetNumber()
        End Sub
        Private Function GetNumber() As Integer
            Return Random.Next(0, Count)
        End Function
    End Class
    Public Class Data
        Implements INotifyPropertyChanged
        Private _Id As Integer
        Public _Text As String
        Public _Progress As Double

        Public Property Id() As Integer
            Get
                Return _Id
            End Get
            Set(ByVal value As Integer)
                _Id = value
                NotifyPropertyChanged("Id")
            End Set
        End Property
        Public Property Text() As String
            Get
                Return _Text
            End Get
            Set(ByVal value As String)
                _Text = value
                NotifyPropertyChanged("Text")
            End Set
        End Property
        Public Property Progress() As Double
            Get
                Return _Progress
            End Get
            Set(ByVal value As Double)
                _Progress = value
                NotifyPropertyChanged("Progress")
            End Set
        End Property

        Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
        Private Sub NotifyPropertyChanged(ByVal name As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
        End Sub
    End Class
End Namespace