Skip to main content

Microsoft Silverlight

Problem while Creating Silverlight Class Library [:(]RSS Feed

(0)

varshavmane
varshavmane

Contributor

Contributor

6263 points

1,489 Posts

Problem while Creating Silverlight Class Library [:(]

Hello all,

I am trying to convert some C# class into Silverlight Class. Following is the link from which I am trying to convert it into Silverlight Class library

http://www.leniel.net/2008/01/breadth-and-depth-first-search-part-2.html

Its has the following classes :

NodeList.cs, Node.cs, Graph.cs, EdgeToNeighbor.cs and AdjacencyList.cs.

Looks like Silverlight doesnt support Hashtable.

Can some please help me out how should I about it.

Thanks in advance.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

Shaji-mji
Shaji-mji

Participant

Participant

1129 points

260 Posts

Re: Problem while Creating Silverlight Class Library [:(]

 Silverlight doesnot support the default visual studio class libraries.

 

You will have to create Silverlight Class Library project and then add your classes inside that !!!.

varshavmane
varshavmane

Contributor

Contributor

6263 points

1,489 Posts

Re: Re: Problem while Creating Silverlight Class Library [:(]

Thanks for the reply. I am trying to create Silverlight Class Library only by Silverlight doesnt support Hash Tables so I was trying to use Dictionary but Sad

Would you please provide me with some info about Dictionary, like how to use them or how do I convert the above mentioned class in Silverlight Class Library.

Thanks again.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

Shaji-mji
Shaji-mji

Participant

Participant

1129 points

260 Posts

Re: Re: Problem while Creating Silverlight Class Library [:(]

 Instead of the Hash Table, Create a class with the columns(in the hash table) as Properties of the class. And use a List<Object> to add the items in the row. for example

 

public class Graph

{

 public int PointX { get; set; }

  public int PointY { get; set; }

}

 

in the function where you want to use the hash table use the following code

 

List< Graph > myTable  = new List< Graph >();

 myTable .Add(new Graph(){ PointX=100, PointY=200});

 myTable .Add(new Graph(){ PointX=110, PointY=220});

 myTable .Add(new Graph(){ PointX=120, PointY=240});

 

You can then Bind this List  "myTable" to a ListBox or ComboBox or DataGrid..

 

let me know if this helps..

 

Thanks

 

varshavmane
varshavmane

Contributor

Contributor

6263 points

1,489 Posts

Re: Re: Re: Problem while Creating Silverlight Class Library [:(]

Thanks for the reply. Im trying to convert that code because I have to create Graph control in Silverlight. I mean Graph not Chart Control.

Where I can Traverse the nodes or from database I can get the values and Draw the Graph.

Can you please help me with this?

Thanks again.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

ksleung
ksleung

Contributor

Contributor

5198 points

993 Posts

Re: Re: Re: Problem while Creating Silverlight Class Library [:(]

I think your best bet is dictionary.

using System.Collections.Generic;

void foo() {
   Dictionary<string, string> dict = new Dictionary<string, string>();
   dict.Add("hello", "world");
   dict.Add("foo", "bar");
   if (!dict.Contains("foo")) throw new Exception();
   string world = dict["hello"];
   if (world != "world") throw new Exception();
}

It is not a hashtable...  I think it is implemented based on binary tree.  For most practical purpose this is good enough.  If not, there are many hash table implementations in C++, or even C#.

weeser
weeser

Member

Member

133 points

96 Posts

Re: Re: Re: Problem while Creating Silverlight Class Library [:(]

Greetings,

Im not sure if this will help much....but i am currently building a c# class library.  We wanted it to be compatable with both asp and silverlight.  Our solution was to make the library in compatable with asp.  But we use a silverlight enabled WCF service to act as the middle man, which mines data using the library and returns it to the silverlight app.

Just an idea anyways Big Smile

Cheers,

Josh, AKA Weeser
Kansas State University-Salina

varshavmane
varshavmane

Contributor

Contributor

6263 points

1,489 Posts

Re: Re: Re: Problem while Creating Silverlight Class Library [:(]

Thanks for the reply. I got one link in which Graph is implemented in Silverlight but that Project doesn't run.

http://www.netfxharmonics.com/2007/05/Reflecting-Graph-Silverlight-Demo.aspx

Everything is done in through Javascript and I cant see xap file in that project.

Can you please tell me is there anyways to convert Javascript code ? This question might be a wrong question but right now Im struggling in implementing graphs.

Please help.

Thanks in advance.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities