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

How to setup XAML for Master/Child based on nested ObservableCollections?

Sort Posts: Previous Next
  •  05-13-2008, 5:51 PM Post no. 12228

    How to setup XAML for Master/Child based on nested ObservableCollections?

    I have an ObservableCollection one of whose member properties is an ObservableCollection. I can get the first level to display correctly, but haven't much idea on how to get the nested collection working.

    I have tried setting up the DataRelationDetailDescription and DetailConfiguration tags but I don't see where the binding to the nested collection is set, or what it should be.

    Does anyone have an full example of how to setup for this case? 

  •  05-14-2008, 8:10 AM Post no. 12239 in reply to 12228

    Re: How to setup XAML for Master/Child based on nested ObservableCollections?

    You can use a PropertyDetailDescription to specify the property in your ObservableCollection that contains the detail data. If you have access to the OC, you can also set the PropertyRelation attribute on the property.

    For more information on detail descriptions, you can refer to the Detail Descriptions topic in the documentation.


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-15-2008, 1:15 PM Post no. 12309 in reply to 12239

    Re: How to setup XAML for Master/Child based on nested ObservableCollections?

    I added a PropertyRelation attribute on the nested collection.

    If I use the default AutoCreateDetailConfigurations="True" then I get a hierarchical  display (big step forward), but have no control over the data displayed (step backward).

    If I use DataGridCollectionViewSource and DataGridCollectionViewSource.ItemProperties then I get control over the content of the Master rows (step forward).

    If I add DataGridCollectionViewSource.DetailDescriptions and DataRelationDetailDescription with DataRelationDetailDescription.ItemProperties for the detail row I get no expand/collapse option and no detail rows at all. 

    The class documentation for DataRelationDetailDescription is tagged with the PRO icon. Could this explain my problems?

    I am still unclear how the DataRelationDetailDescription uses the RelationName attribute to specify the detail collection. I am assuming it is the same as the name for which I added the PropertyRelation. Is there a way to make this explicit in XAML so that the data model does not have to have view specific details added?

    Any help gratefully received.

     

     

     

     

     

     

     

  •  05-16-2008, 8:40 AM Post no. 12328 in reply to 12309

    Re: How to setup XAML for Master/Child based on nested ObservableCollections?

    If you flag a property as being the source of the detail data (PropertyRelation attribute) and set AutoCreateDetailConfigurations to true, you should automatically have details appear. If you see the details, then you either have a Pro license key or a non-expired trial key.

    If you want to provide default detail configurations, then you can play with the grid's DefaultDetailConfiguration property.

    If you want to provide explicit configurations for specific detail configurations, then you can use the grid's (and DetailConfiguration's) DetailConfigurations property.

    If I add DataGridCollectionViewSource.DetailDescriptions and DataRelationDetailDescription with DataRelationDetailDescription.ItemProperties for the detail row I get no expand/collapse option and no detail rows at all. 
     

    If you want to define the item properties that will appear in the details, then you will need to define PropertyDetailDescriptions rather than DataRelationDetailDescriptions, and specifying the property name in the data source that contains your data. Now this may seem conflicting with the previous advice; however, keep  in mind that flagging a property as containing the detail data (PropertyRelation attribute) will result in the automatic creation of  PropertyDetailDescriptions (in the case where they are not explicitly defined in the DataGridCollectionViewSource/DetailDescription's DetailDescriptions property).

    I suggest you take a look at the following Master/Detail topics for more information and examples:

    DataGridCollectionView Overview
    Master/Detail Overview

    Hope this helps!

     


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-18-2008, 11:11 AM Post no. 12354 in reply to 12328

    Re: How to setup XAML for Master/Child based on nested ObservableCollections?

    That did the trick. I can now control which items appear in the master and detail rowsSmile');" title="Smile - Smile">

    The xaml for my application contains:

            <!-- ModelRoot is a singleton (accessible via the static/shared GetInstance method) which provides access to observable collections exposed as properties. E.g. Routes (the master rows in this case). -->

    <Application x:Class="Application"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        StartupUri="winRoutePlanner.xaml"
        xmlns:model="clr-namespace:Dispatcher.Model;assembly=DispatcherModel" >
        <Application.Resources>
            <ObjectDataProvider MethodName="GetInstance" ObjectType="{x:Type model:ModelRoot}" x:Key="ModelRoot"/>
        </Application.Resources>
    </Application>
     

    The window xaml contain:

    <window.Resources>

            <xcdg:DataGridCollectionViewSource x:Key="gridData"
                                        Source="{Binding Path=Routes, Source={StaticResource ModelRoot}}">

                <!--The Master row -->
                <xcdg:DataGridCollectionViewSource.ItemProperties>
                    <xcdg:DataGridItemProperty Name="RouteId" Title="Route#"/>
                    <xcdg:DataGridItemProperty Name="RouteName" Title="Route Name"/>
                </xcdg:DataGridCollectionViewSource.ItemProperties>


                <xcdg:DataGridCollectionViewSource.DetailDescriptions>

                   <!-- "Orders" is the name of the ObservableCollection<Orders> property in the Route object-->
                    <xcdg:PropertyDetailDescription  RelationName="Orders">
                        <xcdg:PropertyDetailDescription.ItemProperties>

                            <!--Specify detail row items here -->
                            <xcdg:DataGridItemProperty Name="OrderId" Title="Order#"/>
                            <xcdg:DataGridItemProperty Name="LocationId" Title="LocationId"/>
                        </xcdg:PropertyDetailDescription.ItemProperties>


                    </xcdg:PropertyDetailDescription>
                </xcdg:DataGridCollectionViewSource.DetailDescriptions>

            </xcdg:DataGridCollectionViewSource>

    </Window.Resources>


    I also removed the PropertyRelation from the Orders Property in the Route (Master) object. The data model now has no view references and I  was able to remove the Xcdg namespace from the model. WTG.

    Many thanks.

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.