Binding to ICollectionView

  • 5 minutes to read

The Grid Control supports ICollectionView binding. If the DataControlBase.IsSynchronizedWithCurrentItem property is set to true, the grid automatically synchronizes its currently selected item with the underlying collection.

Example

The example shows how to bind the Grid Control to the ICollectionView.

Use buttons to select an item in the collection. A checkbox specifies whether the grid's currently selected item is synchronized with the collection.

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ICollectionView_binding"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Grid="using:DevExpress.UI.Xaml.Grid"
    x:Class="ICollectionView_binding.MainPage"
    mc:Ignorable="d">

    <Grid>
        <Grid:GridControl Name="grid" AutoGenerateColumns="True" ShowFixedTotalSummary="True" ItemsSource="{Binding Data}" Margin="0,0,0,40" IsSynchronizedWithCurrentItem="{Binding ElementName=checkBox, Path=IsChecked}" >
            <Grid:GridControl.TotalSummary>
                <Grid:GridSummaryItem x:Name="item" SummaryType="Count" Alignment="Right" />
            </Grid:GridControl.TotalSummary>
        </Grid:GridControl>
        <Button VerticalAlignment="Bottom" HorizontalAlignment="Left" Content="Previous" Click="Button_Left" />
        <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Next" Click="Button_Right" />
        <CheckBox VerticalAlignment="Bottom" HorizontalAlignment="Center" Content="IsSynchronizedWithCurrentItem" Name="checkBox" />
    </Grid>
</Page>