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

starter question about images and how to set them dynamically

Last post 09-14-2008, 7:57 PM by Translucent. 3 replies.
Sort Posts: Previous Next
  •  09-14-2008, 12:52 PM 8367

    starter question about images and how to set them dynamically

    It's probably been asked before, but I can't seem to find any posts or samples about this.

    I'm a long time C++ programmer, but I just started playing with MCML and C# this weekend.  I am just trying random ideas to get a better understanding for how VMC development works. 

    In my current test,  I was imagining a TV show browser and I wanted to create a strip of selectable images.  My entire approach could be flawed and I would certainly welcome any criticism, but the general approach I was taking was to use an array of strings in a cs file, with each string being the URL for an image.

    My understanding is that I should create a UI element in an mcml file that defines a "button", which I could then feed to a repeater.  I was trying to define an image property for the button UI file called "ImageURL" and setting the source to "$Required".  Down in the content block, I was creating a graphic element and setting its Content to be "[ImageURL]".

    So far, the compiler is complaining about:

    Unable to convert "$Required" to an object of type 'Resource'. (Invalid Resource value '$Required')

    My high level question is, how do you create a graphic element and have it reference content that isn't statically available at build time (i.e.: a URL or filename that could change at runtime)?

    If there is an MCML sampler file that demonstrates this, I must have missed it.

    Thanks!





  •  09-14-2008, 3:11 PM 8368 in reply to 8367

    Re: starter question about images and how to set them dynamically

    Instead of an array of images you'll want an array of Image objects, also you'll want to use something like a Choice or an ArrayListDataSet instead of just an Array.

    So, if you have a c# class that contains one of these collection type lists then in your mcml you can use a repeater (and optionally a scroller wrapping that repeater) to show each image.

    The reason for using one of these list classes is that they provide a number of methods that the mcml engine will use to index into them (that is my understanding). Also, if you have a class that you want to change data inside and have the mcml react to it then you'll want to subclass it from ModelItem (found in Microsoft.Mediacenter.UI). I hope this gives you some idea of the direction to go.

    I would personally probably use a Choice list for your images since connecting a ClickHandler to that is super easy. This would likely also be a great time to review the repeater/scroller/Choice features in the MediaCenter SDK documentation.
  •  09-14-2008, 5:16 PM 8369 in reply to 8368

    Re: starter question about images and how to set them dynamically

    Thank you for the info!  I'll start heading down that route.
  •  09-14-2008, 7:57 PM 8371 in reply to 8369

    Re: starter question about images and how to set them dynamically

    No problem, that was all of memory so if any of it is wrong Im sorry, just post other questions and we'll all answer as best we can. Good luck, I must say mcml is quite a fun ride!
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems