Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit Problem while Creating Silverlight Class Library [:(]
7 replies. Latest Post by varshavmane on June 30, 2009.
(0)
varshavmane
Contributor
6263 points
1,489 Posts
06-26-2009 6:35 AM |
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.
Shaji-mji
Participant
1129 points
260 Posts
06-26-2009 7:12 AM |
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 !!!.
06-26-2009 7:17 AM |
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
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.
06-26-2009 7:34 AM |
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
06-26-2009 8:24 AM |
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?
ksleung
5198 points
993 Posts
06-26-2009 12:42 PM |
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
Member
133 points
96 Posts
06-26-2009 1:57 PM |
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
Cheers,
06-30-2009 9:39 AM |
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.