Binding xml file in coverflow

4 posts, 0 answers
  1. Hernan
    Hernan avatar
    4 posts
    Member since:
    Nov 2010

    Posted 18 Dec 2010 Link to this post

    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.

  2. George
    Admin
    George avatar
    1332 posts

    Posted 23 Dec 2010 Link to this post

    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
  3. DevCraft banner
  4. Hernan
    Hernan avatar
    4 posts
    Member since:
    Nov 2010

    Posted 04 Jan 2011 Link to this post

    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.
  5. George
    Admin
    George avatar
    1332 posts

    Posted 06 Jan 2011 Link to this post

    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
Back to Top