Home Forums WPF controls Xceed DataGrid for WPF Noob needs help with binding

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26592 |

    I’ve done this before in plain XAML but this is my first go with Xceed’s DataGrid.

    I’m trying to bind an XML data source to a DataGrid:

    <Window x:Class=”MyProject.Window1″
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:local=”clr-namespace:Xceed.Wpf.Documentation”
    Title=”Exocet” Height=”496″ Width=”700″ Background=”#FF3B3B3B” xmlns:my=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid” xmlns:my1=”clr-namespace:Xceed.Wpf.DataGrid.Views;assembly=Xceed.Wpf.DataGrid”
    Loaded=”window_Loaded” Closing=”DataWindow_Closing” BorderThickness=”3″>

    <Grid>
    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <Grid.Resources>
    <XmlDataProvider x:Key=”Data” Source=”c:\program files\msts\serialized.xml” XPath=”/MSTSSchedule/m_Schedule”/>
    <xcdg:DataGridCollectionViewSource x:Key=”c:\program files\msts\serialized.xml” Source=”{Binding Source={StaticResource Data}}”>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <local:XmlDataGridItemProperty Name=”Summary” DataType=”{x:Type s:String}” Title=”Summary” />
    </xcdg:DataGridCollectionViewSource.ItemProperties>
    </xcdg:DataGridCollectionViewSource>
    </Grid.Resources>

    <xcdg:DataGridControl Margin=”12,48,12,46″ x:Name=”XmlGrid”
    ItemsSource=”{Binding Source={StaticResource Data}}”>
    <my:DataGridControl.View>
    <my1:TableView>
    <my1:TableView.Theme>
    <my1:AeroNormalColorTheme />
    </my1:TableView.Theme>
    </my1:TableView>
    </my:DataGridControl.View>

    </xcdg:DataGridControl>

    I have added XmlPropertyDescriptor and XmlDataGridItemProperty classes to my project.

    Here’s the errors I get in the Designer (VS2008 btw):

    1) Type ‘String’ was not found

    2) ‘s’ is an undeclared namespace

    What am I doing wrong here… I have to admit XAML binding is a very confusing topic to me.

    Imported from legacy forums. Posted by yahgrid27 (had 2134 views)

    User (Old forums)
    Member
    Post count: 23064

    Don’t worry, you’ve made a very simple mistake 🙂

    You say: s:String, which basically means: find type String in namespace ‘s’. All of those namespaces are defined at the top of the code:

    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:<b>x</b>=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:<b>local</b>=”clr-namespace:Xceed.Wpf.Documentation”
    xmlns:<b>my</b>=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid” xmlns:<b>my1</b>=”clr-namespace:Xceed.Wpf.DataGrid.Views;assembly=Xceed.Wpf.DataGrid”

    So all you need to do is add this namespace, and you’re ready to go!

    xmlns:<b>s</b>=”clr-namespace:System;assembly=mscorlib”

    Imported from legacy forums. Posted by Frances (had 3101 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.