Silverlight menu function error

Hi,

code = vb.net
Enviroment: Silverlight 4 RC

Please look at the below code, I have highlighted lines with errors. Essentially this is a menu in a silverlight application , when I click over the menu it should open the menu with further submenus.Can you please advise how I can fix these errors?


 Private Sub getMenuItems(ByVal xml As XElement)
        Dim lstItems = From p In xml.Elements("Item") _  <----- I get error Error "Expression of type 'Object' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider."
        Select p
        For Each el In lstItems < ----- I get error " Expression is of type 'Object', which is not a collection type."      
            Dim Text As String = el.Attribute("Text").Value
            Dim Id As Integer
            Int32.TryParse(el.Attribute("Id").Value, Id)
            If el.HasElements = False Then
                lstMenuItems.Add(New MenuItem(Text, Id, 0, 0))
            Else
                lstMenuItems.Add(New MenuItem(Text, Id, 0, el.Elements("Item").Count()))
                Dim subItems = From pSub In el.Elements("Item") _
                    Select pSub
                For Each [sub] In subItems
                    Text = [sub].Attribute("Text").Value
                    Int32.TryParse([sub].Attribute("Id").Value, Id)
                    lstMenuItems.Add(New MenuItem(Text, Id, 1, 0))
                Next
            End If
        Next
LVL 1
SeosaimhAsked:
Who is Participating?
 
HeiniHogCommented:
Your problem is that you have declared your own class called "XElement". Please delete the class declaration for "XElement" and make sure you are referencing the System.Xml.Linq assembly.
0
 
SeosaimhAuthor Commented:
Hi,

Anybody able to help, I resolced the second error, just the first I need help with..

thanks
0
 
HeiniHogCommented:
This is most likely because you are missing an assembly reference. To query System.Xml.Linq.XElement objects, you need to reference "System.Core".
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
SeosaimhAuthor Commented:
I have added the below and it still is appearing the error

"Expression of type 'Object' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider."

what else could be casuing it?
0
 
SeosaimhAuthor Commented:
this was added sorry:
Option Infer On
Option Strict Off
Option Explicit On
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports System.Xml.Linq
Imports System.Core
0
 
HeiniHogCommented:
You don't need to (or can) include an "Imports" statement. You need to reference the assembly. If you are using Visual Studio or SharpDevelop, you should be able to do this by right-clicking on the project in the Solution pane.
0
 
SeosaimhAuthor Commented:
Just added the reference to the project, and when I hit ctrl f5 the error is still appearing. What else can I do?
0
 
HeiniHogCommented:
Is there any chance that you could share the relevant project? If not, could you share the single file?
0
 
SeosaimhAuthor Commented:
have a look at the attached. the menu is developed in expression blend , as such has xaml behind it,  but no need for this to be atatched I think.
Doc1.doc
0
 
SeosaimhAuthor Commented:
Do you  see sp.menu?  That is referenced about eight times, but in each one I am getting the following error:

"Option strict on disallows late binding."   -  how do I fix this? I can switch it off, but I understand this causes problems at run time..
0
 
SeosaimhAuthor Commented:
Hi, any help please?
0
 
SeosaimhAuthor Commented:
resolved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.