RSS
 

Archive for the ‘Silverlight’ Category

Help me, my xap file is not updated!

06 Oct

Did you ever had the feeling that sometimes you really loose your mind? I’ve got it all the time and especially when you’re expecting something that doesn’t seem to happen.

I was using Chrome as browser and my xap file wasn’t updating after a build. I thought it was visual studio, so I checked the Solution Dependencies but they were all okay. The next thing to do was to clean the solution, clean the projects, build the solution, rebuild the solution. Deleting my generated xap files… the old xap file was still in my browser window.

Probably, Google Chrome also caches a bit of your browser history. You should clean your History if you have this problem. After cleaning, the new changes were visible!

If it still doesn’t work, use another browser to test.

 
 

Entity FrameWork, Deleting Item and Re-adding it.

04 Oct

This is my first try out with the Entity Framework as I was playing with the RIA Services for Silverlight 3. If you use the latest technology, let’s try the Entity Framework instead of the older LINQ2SQL technology.

My first problem that I ran into was readding a deleted table. When you delete a table from the design surface, it leaves some references that makes it unable to add the old item again.

If you look at your *.edmx file with a XML Editor (In visual studio, right click your edmx file -> Open With -> XML Editor), you’ll have to remove the traces that are left after the deletion.

Do a search for your table name, the deletion will include all EntitySets, EntityType, AssociationSets, Associations, …

If you removed all the related data, you can update your model and Readd the desired table!

Let’s continue the EF journey

 
 

Custom Tool Warning (Silverlight Add Web Reference in VS2008)

13 Jul

Last friday, I was updating my WCF Service Reference on a Silverlight Project in Visual Studio 2008 and I came across following error / warning:

Custom tool warning: An item with the same key has already been added.

Custom tool warning: An item with the same key has already been added

Custom tool warning: An item with the same key has already been added

Okay, it’s a warning, so what’s the point? Well it results in an incomplete generation of your WCF Code. So if you’re trying to build Visual Studio will say: Are you missing a using directive or an assembly reference? In fact we do…

After a lot of research, I didn’t find any good solution to get rid of the problem, but after a while I was getting the point. If you are returning an type that has not been build by the Silverlight Framework, you’ll get this error.

This code proves it:

A DataSet is not known by the Silverlight Framework, so if we include it as a return type in our service, it will fail to add the service correctly.

service.svc.cs

public DataSet GetTrackingTableDS(String TableName)
{
return new DataSet();
}

service Interface:

[OperationContract]
DataSet GetTrackingTableDS(String TableName);

Most posts I found about this error state that it went away after deletion of a method in the WCF Service. Well it’s correct but this should clarify some things for you!

Solution, just add another WCF Service in your project only for the methods that Silverlight recognize and call it from your silverlight project.

UPDATE
As you can have this error in serveral occasions, sometimes it helps to turn off “Reuse Types in referenced assemblies”

custom tool error

 

Silverlight 2 DataGrid ObservableCollection

26 Jun

I had a hard time figuring out why my DataGrid wasn’t updated when I was using an ObservableCollection. Sometimes it was updated, sometimes it wasn’t. Because of the complexity of my Objects I didn’t see it at first sight. The problem was due to the update of my ObservableCollection. I was getting my updated object (sometimes it changed, sometimes not, so that’s why it was tricky…) back from my WCF service and replaced my Observable object with it. Because of the way ObservableCollections work, this will result in a misbehaviour of your result grid.

You should use the .Add(), .Remove() and .Clear() methods instead. Yeah, we all know this, but sometimes, you miss it ;)

First Clear() your object, then rebind it using a foreach and applying the Add() methods.

I included a simple project to explain the way how ObservableCollections can be used by the Silverlight 2 DataGrid.

DataGrid with ObservableCollection

Project Sample: observablecollections

 
 

Silverlight 2 Enabling Right Click

08 Jun

Microsoft didn’t include the functionality to customize the Right Mouse Click in a Silverlight Application. But there is a workaround and there isn’t much coding involved.

The workaround does limit your application behaviour. In the ASPX page where you’re calling the Silverlight Application, you can put a Windowless property to true.

MSDN information: http://msdn.microsoft.com/en-us/library/system.web.ui.silverlightcontrols.silverlight.windowless(VS.95).aspx

Complex animations and high definition video content will not perform well in windowless mode. To compensate, you can adjust the frame rate for Silverlight content by using the MaxFrameRate property. However, you should also test your code with a variety of platforms and browsers when you use windowless mode.

The limitations of windowless mode are as follows:

  • Performance issues. Windowless mode is computationally expensive, especially in combination with a transparent plug-in background. For more information, see Performance Tips.
  • No support for passing mouse input to HTML content that the plug-in overlaps, even if the plug-in has a transparent background. To process mouse input through HTML, the HTML must overlap the Silverlight plug-in.
  • No mouse capture support outside the boundary of the plug-in.
  • No accessibility or IME support.
  • No support for windowless mode in full-screen mode.
  • No support for suppressing popup blockers when using hyperlink navigation to new windows. Also, note that popup blocker suppression is not supported on Safari regardless of the windowing mode.
  • Issues because of browser and platform limitations:
    • Visual tearing in animation and video playback on Windows XP, on Windows Vista with DWM disabled, and in Internet Explorer, regardless of platform.
    • Unreliable rendering when overlapping HTML content in Safari.

Focus issues in Mozilla-based browsers. When the focus moves between the plug-in and other plug-ins or HTML controls, multiple controls will sometimes appear to have focus.

To implement the Custom Right Mouse Click on Silverlight 2 Application: http://silverlight.net/blogs/msnow/archive/2008/07/01/tip-of-the-day-14-how-to-right-click-on-a-silverlight-application.aspx

Source Project: Custom Right Mouse Click