Gridview with multiple sources/propertypaths? RRS feed

  • Question

  • All,

    I'm developing an app that will show users a dashboard of resources on their server.

    Broadly I have 3 main classes involved in the data model: Server, Domain, RegisteredResource. These each extend a 'SmashObject' base class.

    The Server object is acting as a container and contains several observable collections like so:

    private ObservableCollection<Domain> _allDomains = new ObservableCollection<Domain>();
            public ObservableCollection<Domain> AllDomains
                get { return this._allDomains; }
            private ObservableCollection<RegisteredResource> _allResources = new ObservableCollection<RegisteredResource>();
            public ObservableCollection<RegisteredResource> AllResources
                get { return this._allResources; }

    In my UI I want to be able to show both the Domains and Resources in a single Gridview - so I can still use semantic zoom on it. As each extend the same base class I could create a new collection of type <SmashObject> and combine the two sets, however the PropertyPaths will be different for each main type.

    So does anyone have any advice for how to approach this problem? Is there a way to have multiple GridViews in a single semantic zoom for example? Is there a way of 'typeof' checking in Xaml?

    All suggestions appreciated.



    Thursday, January 23, 2014 8:04 AM


  • What I think you'll need to do is have an ObservableCollection of UIElements that can contain custom usercontrols that represent the different values.  Loop over all of your collections, one by one, and for each different type of element, add a usercontrol to the OC of UIElements that represents that element, with the proper values.  Allow the GridView to render the proper usercontrol for each element without explicitly using a datatemplate.  I think this will work.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Anne Jing Monday, February 10, 2014 1:46 AM
    Thursday, January 23, 2014 5:00 PM