Bonjour,


Je fais du vb dans un projet silverlight. Je suit un tutoriel du coach silverlight
(http://msdn.microsoft.com/fr-fr/silv.../cc512801.aspx) ecrit en c# mais je bloque sur ma requete , voici mon erreur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Impossible d'effectuer un cast de l'objet de type 'WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,SilverlightApplication8.Diggstory]' en type 'System.Collections.Generic.IEnumerable`1[System.Xml.Linq.XElement]'.

ma classe applicative:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
Public Class Diggstory
 
    Public Id As Integer
    Public Title As String
    Public Description As String
    Public HrefLink As String
    Public NumDiggs As Integer
    Public ThumbNail As String
    Public UserName As String
End Class

mon code vb:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub search_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Dim topic As String
        Dim diggUrl As String
        Dim diggService As WebClient

        topic = research.Text

        diggUrl = String.Format("http://services.digg.com/stories/topic/{0}?count=20&appkey=http%3A%2F%2Fscottgu.com", topic)

        diggService = New WebClient()
        '  Specify that the DiggService_DownloadStoriesCompleted method gets called
        '  when the download completes.
        AddHandler diggService.DownloadStringCompleted, AddressOf DiggService_DownloadStoriesCompleted
        diggService.DownloadStringAsync(New Uri(diggUrl))
    
    End Sub


    Private Sub DiggService_DownloadStoriesCompleted(ByVal sender As System.Object, ByVal e As DownloadStringCompletedEventArgs)

        Dim result As String

        If (e.Error Is Nothing) Then
            'result = e.Result
            DisplayStories(e.Result)

            'id.Text = result
        Else
            ' id.Text = "error"
        End If

    End Sub

    Private Sub DisplayStories(ByVal xmlContent As String)
        Dim document As Xml.Linq.XDocument
        document = Xml.Linq.XDocument.Parse(xmlContent)
        Dim res As IEnumerable(Of Xml.Linq.XElement) = From story In document.Descendants("story") _
                                                       Where story.Element("thumbnail") IsNot Nothing _
                                                       Select New Diggstory With {.Id = Val(story.Attribute("id")), .Title = story.Element("title").ToString, .Description = story.Element("description").ToString.Trim(), .ThumbNail = story.Element("thumbnail").Attribute("src").Value.ToString, .HrefLink = (New Uri(story.Attribute("link")).ToString), .NumDiggs = Val(story.Attribute("diggs")), .UserName = story.Element("user").Attribute("name").Value.ToString}
                         
        StoriesList.ItemsSource = res

    End Sub


End Class
Merci pour votre aide