Hierarchical Objects from Serialized XMLC:\Users\rblack\Documents\visual studio 2010\Projects\MultipleLevelObject

4 posts, 0 answers
  1. Mark Peterson
    Mark Peterson avatar
    8 posts
    Member since:
    Feb 2010

    Posted 03 Jun 2010 Link to this post

    *Edit* Please fix title to say "Hierarchical Objects from Serialized XML"

    I have decided to go away from xml databinding and instead use object databinding because of the advantages you get using OnPropertyChanged.  The easiest way to get this done is to create a xsd of your xml and then use a program called Xsd2Code to have all your properties contain OnPropertyChanged.

    I have created the xsd and generated file with no problems, but I can not get the treeview to display the serialized data.

    I am having problems going more than 1 layer deep.  I am including my sample program to keep this post shorter and easier for everyone.  It can be found here

    Thanks in advance
    Mark




  2. Mark Peterson
    Mark Peterson avatar
    8 posts
    Member since:
    Feb 2010

    Posted 04 Jun 2010 Link to this post

    For anyone looking at this, I have made some small fixes to get the first set of XML nodes.

    There was a bug in my test.xsd that was generated that had the numbers xml node be optional.  
    A new version of the code can be found here.

    Thanks
    Mark


  3. UI for WPF is Visual Studio 2017 Ready
  4. Mark Peterson
    Mark Peterson avatar
    8 posts
    Member since:
    Feb 2010

    Posted 11 Jun 2010 Link to this post

    Have there been any updates to this question?

    Thanks
    Mark
  5. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 16 Jun 2010 Link to this post

    Hello Mark Peterson,

    I've modified your example a little and now is OK. Since you are having one type of items for the whole hierarchy, you shouldn't have different HierarchicalTemplates, but only one for the whole tree:
    <Grid>
        <Grid.Resources>
     
            <HierarchicalDataTemplate x:Key="Test"
                                        ItemsSource="{Binding Number1}">
                <Border>
                    <Label VerticalContentAlignment="Center">
                        <TextBlock Text="{Binding val}"
                                    VerticalAlignment="Center"
                                    TextWrapping="Wrap" />
                    </Label>
                </Border>
            </HierarchicalDataTemplate>
     
        </Grid.Resources>
     
        <telerik:RadTreeView ItemsSource="{Binding Source={StaticResource TestXML}, Path=TestingDataSource}"
                                ItemTemplate="{StaticResource Test}" />
    </Grid>

    Hope this works for you.

    Greetings,
    Miro Miroslavov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top