The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Can you inherit from Repeater or define ContentSelectors from code?

Last post 07-10-2010, 12:01 AM by AndyC. 5 replies.
Sort Posts: Previous Next
  •  07-06-2010, 6:00 AM 9703

    Can you inherit from Repeater or define ContentSelectors from code?

    Hi

    I am trying to create a 2 level ui interface structure. I divide the interface structure in 2 part. The base part is to be able to reuse the logic for navigation and clicking operations etc. Then each of the actual pages, specific to the plugin as another part.

    I place the menu structure in a separate dll. Then I reference this dll in the actual plugin and just add the menuoption through code. Thereby using a single tag and the code to add the menu options and get a full working menu, and re-useable.

    Now I have to do the same thing for content area. (a content page for each menu item), the question is how to model this in mcml?

    (to better understand what I am trying to do, is to look at WMC and then look at the Music library. I have duplicated the logic and behavior of this menu and now want to simulate the content pages. Like if you go through the different menu items, you see the layout differs e.g. at “Album artists”. )

    I think the repeater is best for this use, so I can get the “slide to the left, when going left in the menu, and slide to the right when going to the right”. Then using the ContentSelector to be able to create different layouts for the different pages. However I fail to specify these content selectors from the addin dll, along with the content elements.

    In short: The logic for handle the navigation and behavior is placed in a common dll. The logic for specifying is placed in the specific plugin dll.

    I also tried to inherit from “Repeater”, to create my own object, but it seems to be protected.

    Hope this makes sense and anyone knows how to do it.

    Thanks

    Kim
  •  07-07-2010, 12:31 AM 9704 in reply to 9703

    Re: Can you inherit from Repeater or define ContentSelectors from code?

    Hi Kim,

    You can't inherit any of the ViewItem classes (of which Repeater is one). To pass information between UIs you have to use ModelItems instead. To pass instructions between UIs you can use Command and invoke it when you want something to happen.

    The concept of reusable DLLs for Media Center UI compenents is an admirable one, however adds a level of complexity which is not always a good thing. I recommend you consider re-using at the source code level rather than the assembly level, so your add-in is self contained rather than dependent on an assembly that could be modified by another add-in installation.

    Finally, the work involved in making a generic gallery view is quite significant and dependent on all of your subsequent UI items adopting a complementary approach (e.g. implementing something like an IGalleryItem interface so they can all be accessed by the generic UI) which doesn't appear worth the effort vs. the small amount of time to create a specific gallery view for each add-in you do.

    Cheers,
    Andrew
  •  07-07-2010, 2:38 AM 9706 in reply to 9704

    Re: Can you inherit from Repeater or define ContentSelectors from code?

    It does not sound right to solve this using commands.

    The attribute "BaseUI" not intended for this?

    And what about using code to access ViewItems - can you do that?

    Yes, up front it easy and faster to do it your way - even more if it not supported by the framework itself.

    Thanks

    Kim
  •  07-07-2010, 1:14 PM 9708 in reply to 9706

    Re: Can you inherit from Repeater or define ContentSelectors from code?

    You can inherit your own UIs with BaseUI but you can't inherit built-in ViewItems.

    You can't access ViewItems from code - Media Center strictly enforces model-view separation.

    Cheers,
    Andrew
  •  07-07-2010, 11:52 PM 9710 in reply to 9708

    Re: Can you inherit from Repeater or define ContentSelectors from code?

    Hi Andrew

    I think I found an easy solution. Once you have setup the dll reference and pre/post build steps, then it no extra work – pure benefit.

    1. Create the common dll
    2. Create a number of classes of page types, like “List, DetailedList, Card, etc.”
    3. Create a ui element and place a repeater inside
    4. Add a typeselector for each of the page types classes you created in step 2
    5. Define content elements for each of these for showing the default layout
    6. Create your addin dll
    7. Add a UI element based on the ui element created in step 3
    8. Create the list of pages based on the classes you created in step 2, then add it to the element created step 7.

    Now all is shown in default rendering

    To override the different page types, create Content elements named the same as the page type classes you want to override, then each plugin can define its own layout if not ok with the default.

    Br

    Kim
  •  07-10-2010, 12:01 AM 9711 in reply to 9710

    Re: Can you inherit from Repeater or define ContentSelectors from code?

    Appreciate it is possible - I have done things this way in the past.

    What you'll find is that you will get different scenarios now that will require your MCML to be slightly different, or you will improve on your controls...

    When that happens you'll either need to make sure that your changes are backwards compatible, or recompile your old apps to work with the new changes, or you'll need to create a new version of the assembly (defeating the object of having a reusable one, as you'll now have two versions in the GAC), and you'll need to maintain both.

    Good luck!

    Cheers,
    Andrew
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems