This project is read-only.

Cool Menu - How to load images from database?

Dec 15, 2008 at 5:39 AM
How can we load images from a database dynamically instead of a fixed folder.
Coordinator
Dec 15, 2008 at 1:20 PM
Since there is no direct way to pull data from a database in Silverlight.  You would first have to build a web-service, HttpHandler, or ASPX page to serve up the image.  Once you have done this, you can specify an Image with the appropriate path.  For example:
            <sc:CoolMenu Height="130" MaxItemHeight="100" MaxItemWidth="100">
                <sc:CoolMenu.Items>
                    <sc:CoolMenuItemCollection>
                        <sc:CoolMenuItem Text="Box">
                            <sc:CoolMenuItem.Content>
                                <Image Source="http://mydomain.com/myfile.aspx?id=34343" Stretch="UniformToFill" Margin="5"  />
                            </sc:CoolMenuItem.Content>
                        </sc:CoolMenuItem>
...
...
Below are a few resources that might help you:
http://sniptools.com/vault/creating-dynamic-images-in-aspnet
http://www.davidhayden.com/blog/dave/archive/2008/10/22/ASPNETWebsiteDevelopmentDisplayingImagesSQLServerDatabase.aspx

I hope this helps!


Jan 22, 2009 at 9:31 AM
I see a Observable Collection and Binding properties on the CoolMenu object.
I guess you should be able databind the Source of the Image to a Uri.
There are enough examples on that on the web.

Does this work in CoolMenu?

Coordinator
Jan 22, 2009 at 1:06 PM
I am currently working on a major refactoring for this control which should allow for databinding.  I will post an example of this as soon as the refactoring is completed.