This is a migrated thread and some comments may be shown as answers.

Binding xml file in coverflow

3 Answers 45 Views
CoverFlow
This is a migrated thread and some comments may be shown as answers.
Hernan
Top achievements
Rank 1
Hernan asked on 18 Dec 2010, 08:51 PM
Hi guys,
We have created a dynamic Xml file that contains both image and video files. I was wondering if this is possible to insert within the Coverflow control. Following your sample code for Coveflow Data Binding, I am not sure how to pass our Xml file instead of the Flicker web service you are using in your example.
Can you show me a sample or guide me on how to bind my

http://silverlight.techmediaconsultant.com/sqlxml/xmltemplate/getMedia.xml?top=100 for Image Source in code behind. We are working with VB 2010  but if video and images can't go together we will split them apart but still need your help binding our Xml.

Public
Sub New()

 

InitializeComponent()

 

 

Dim webClient As New WebClient()

 

 

 

AddHandler webClient.DownloadStringCompleted, AddressOf Me.OnDownloadStringCompleted

 

webClient.DownloadStringAsync(

 

New Uri("http://silverlight.techmediaconsultant.com/sqlxml/xmltemplate/getMedia.xml?top=100", UriKind.Absolute))

 

 

 

End Sub

 

 

 

 

<--HERE BELOW IS WHERE WE CANNOT FIGURE OUT HOW TO PASS OUR XML-->

 

 

 

Private Sub OnDownloadStringCompleted(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)

 

 

 

    Dim ImagesCollection As New ObservableCollection(Of Uri)()

 

 

 

    Dim feed As XDocument = XDocument.Parse(e.Result)

 

 

 

    For Each entry As XElement In feed.Root.Elements(XName.[Get]("entry", "http://www.w3.org/2005/Atom"))

 

 

 

        Dim links As String() = (From link In entry.Elements(XName.[Get]("link", "http://www.w3.org/2005/Atom")) _

 

 

 

        Where String.Compare(link.Attribute(XName.[Get]("rel")).Value, "enclosure") = 0 _

 

 

 

        Select link.Attribute(XName.[Get]("href")).Value).ToArray()

 

 

 

    If links.Length > 0 Then

 

 

 

 

        ImagesCollection.Add(New Uri(links(0), UriKind.Absolute))

 

 

 

    End If

 

 

 

 

    Next

 

 

 

 

    Me.coverflow.ItemsSource = ImagesCollection

 

 

 

End Sub

 

End

 

 

Class

 

 

 

 

Hernan.

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 23 Dec 2010, 01:29 PM
Hi Hernan,

This is the right way to get the xml via WebClient. In the OnDownloadStringCompleted handler you need to add your custom logic in order to get the elements, located in the  DownloadStringCompletedEventArgs.Result

Greetings,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Hernan
Top achievements
Rank 1
answered on 04 Jan 2011, 06:25 AM
Thanks for your reply.
I'm basically new at this and it's like on-the-job-trainning so when you say apply your logic I got ridiculosly stuck in the mud. All I want is to show the elements in the coverflow control.
Is the DownloadStringCompletedEventArgs the only option to apply here? Any other hint or sample on how to get this done?
Please take a look at the webservice I'm working with:

http://silverlight.techmediaconsultant.com/sqlxml/xmltemplate/getMedia.xml?top=100

Hernan.
0
George
Telerik team
answered on 06 Jan 2011, 05:19 PM
Hello Hernan,

 
Attached you can find the sample. I hope this helps.

All the best,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
CoverFlow
Asked by
Hernan
Top achievements
Rank 1
Answers by
George
Telerik team
Hernan
Top achievements
Rank 1
Share this question
or