Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Re: DataGrid Binding XML with LINQ

  •  05-03-2008, 1:36 PM

    Re: DataGrid Binding XML with LINQ

    The "Binding to a LINQ query (XML) example in the documentation should help you get started:

    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
      <Grid.Resources>

        <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                        
    Source="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},
                                         
    Path=XmlData}"/>

      </Grid.Resources>

     

      <xcdg:DataGridControl x:Name="OrdersGrid"
                           
    ItemsSource="{Binding Source={StaticResource cvs_orders}}"/>

    </Grid>

     CODE_BEHIND

    public IEnumerable XmlData
    {
     get
     {
       XDocument document = App.NorthwindDocument;

       var data = from order
    in document.Element( "dataroot" ).Descendants( "Orders" )
                  select
    new
                  {
                    
    ShipCountry = order.Element( "ShipCountry" ).Value,
                    ShipCity = order.Element(
    "ShipCity" ).Value,
                    ShipAddress = order.Element(
    "ShipAddress" ).Value,
                    ShipName = order.Element(
    "ShipName" ).Value,
                    ShipVia = order.Element(
    "ShipVia" ).Value,
                    Freight = order.Element(
    "Freight" ).Value
                  };
       
    return data.ToList();
     }
    }

     


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
    Filed under: ,
View Complete Thread
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.