Sunday, September 12, 2010

Charts in Silverlight

hi,
I have been searching for a different types of charts in silverlight .I found a open source control called Visifire that supports WPF and Silverlight with the option of 3D View.
Here is the link to draw the chart control.

http://visifire.codeplex.com/

Wcf Data Service

Hi
I have created a basic WCF Dataservices using ADO.net entity framework in silverlight. When i about to create method and access it i m getting error as bad request,Error in query syntax.

I have created Wcf Dataservice as
public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);

config.UseVerboseErrors = true;
}

[WebGet]
public string GetUsers(string userId)
{
return "my data";
}

my browser uri is
http://localhost:50449/DataService.svc/GetUsers?userId='1'


And here is the Code from Client:
public void LoadData(string userId)
{
var qry = ctx.CreateQuery("GetUsers").AddQueryOption("UserId", string.Format(@"'{0}'", userId));

qry.BeginExecute(new AsyncCallback(OnLoadComplete), qry);

}
When i execute via browser uri i m getting the result. Not by accessing via method in SL.
I found in SL it adds () in browser URI as like this
http://localhost:50449/DataService.svc/GetUsers()?userId='1'

After a long search we can execute the method as mentioned below which solve me the problem.

ctx.BeginExecute(new Uri(string.Format("{0}GetUsers?UserId={1}", smileEntites.BaseUri, "'1' "), UriKind.RelativeOrAbsolute), OnLoadComplete, null);

void OnLoadComplete(IAsyncResult result)
{

try
{
// Get the results and add them to the collection
IQueryable queryResults = smileEntites.EndExecute(result).AsQueryable();
foreach (var coursw in queryResults)
{
}


}
catch (Exception ex)
{
if (HtmlPage.IsEnabled)
{
HtmlPage.Window.Alert("Failed to retrieve data: " + ex.ToString());
}
}
}

Wednesday, April 21, 2010

Bypassing the Image Cache

Hi,
By default Silverlight will not download an image more than once if is contained within the image cache. That is, as long as the URI remains the same it will reference the image from the cache.
So what if the image changed on the server even though it has the same URI? Your application can force an update by setting the property IgnoreImageCache to true.
Example:
Image img = new Image();

Uri uri = new Uri("http://YourServer.com/MyImage.png", UriKind.Absolute);
BitmapImage bi = new System.Windows.Media.Imaging.BitmapImage(uri);
bi.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
img.Source = bi;
LayoutRoot.Children.Add(img);