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

How to: Bind a Grid to an XML File

  • 2 minutes to read

This example demonstrates how to read data from an XML file and display it using the DXGrid control. If required, the changes made can be saved back to an XML file by clicking the button displayed below the grid.

<Window x:Class="DXGrid_BindingToXML.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        Title="Window1" 
        Height="292" 
        Width="533"
    >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>

        <dxg:GridControl 
            x:Name="grid" 
            VerticalAlignment="Top">
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="FirstName" />
                <dxg:GridColumn FieldName="LastName" />
                <dxg:GridColumn FieldName="Company" />
                <dxg:GridColumn FieldName="City" />
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" />
            </dxg:GridControl.View>
        </dxg:GridControl>
        <Button Margin="5" Grid.Row="1" Click="Button_Click" VerticalAlignment="Bottom" HorizontalAlignment="Left" Content="Post Data to an XML File"/>



    </Grid>
</Window>