Peter McGrattan’s Weblog

Silverlight, WCF, ASP.NET, AJAX, Graphics, RIA

Posts Tagged ‘Silverlight 2 Beta 2’

Samples Updated to Beta 2

Posted by petermcg on June 10, 2008

The API and documentation changes and the fact that Beta2 will not run applications that target Beta1 has obliged me to update links and all the samples previously posted on this blog such as the Pie Chart and Stock List Demo.  From this point on all posts will target Silverlight 2 Beta 2.

I started with a brand new Beta 2 solution when updating each sample to keep things clean.  The changes required to make the the new Pie Chart Solution work included updating the parameter list for the calls to the static Register method for the Dependency properties in the PieChart class now they require an instance of the PropertyMetadata class; a similar change to the Storyboard.SetTargetProperty method calls in PieLayoutManager that now require an instance of the PropertyPath class.  The need to add the MouseEnter animation Storyboard to the resources of the PieChart Canvas is removed thanks to the new support for the ability to create Storyboards in code that can animate parts of the render tree without having to be added to it.

The Stock List Demo Part 3 sample required the same changes for Storyboard.SetTargetProperty and also benefited from the fact that Storyboards created in code no longer have to be added to the Resources of a FrameworkElement for the stock highlight animations to work.  Other changes I ran into included that EventHandler<T> now requires T to inherit from EventArgs, the DataGrid’s AutoGenerateColumns is now true by default, displays itself using a smaller font by default and supports auto-sized columns.

The biggest change to the Stock List Demo project for Beta 2 was the new policy requirements around creating a Sockets server which have been implemented in the updated sample :

Console.WriteLine("Accepting Policy Requests...");

// Read policy file
byte[] policyBytes = File.ReadAllBytes("PolicyResponse.xml");

using (Socket client = policyListener.AcceptSocket())
    Console.WriteLine("Policy Request Accepted...");

    // Get policy request header
    byte[] buffer = new byte[1024];
    int bytesReceived = client.Receive(buffer);

    // Basic check of request header
    string header = Encoding.UTF8.GetString(buffer, 0, bytesReceived);

    if (header == "<policy-file-request/>")
        client.Send(policyBytes, 0, policyBytes.Length, SocketFlags.None);

Please download the latest version for a substantial demonstration of many areas of Silverlight development including Socket interaction that complies with the new policy changes in Silverlight 2 Beta 2.

As part of the upgrade I did run into this issue of not being able to discover a WCF web-service in the same solution after installing Beta 2 when creating the new solution for Stock List Demo 3.  The workaround at the end of the thread here solved the problem.

Please feel free to download the updated samples and as usual let me know any thoughts by adding a quick comment.


Posted in Pie Chart, Silverlight, Sockets, WCF | Tagged: , | 3 Comments »

Silverlight 2 Beta 2

Posted by petermcg on June 10, 2008

After a Beta 1 public release that lasted approx three months, Silverlight 2 has now moved on to Beta 2.  This is the first release of Silverlight 2 that has a commercial go-live license, removing another potential obstacle in the decision to adopt the technology for new development.

Plenty of blogs have an overview of the changes here, here, here and here for a start!  Some highlights that I will pick out are that we can ultimately expect over 100 controls for Silverlight, all of which will have built-in support for Control Templates and Visual State Manager customisation.

The Visual State Manager (VSM) is a way to visually manipulate the ‘Parts Model’ of a control and is supported by Expression Blend 2.5 June 2008 Preview.  This is the different visual states and the transition between those states a control allows a designer to modify or completely customize with the guarantee that the logic of the control will not be adversely affected.  The VSM is a feature new to Silverlight 2 that is not currently in WPF; in order to maintain upwards compatibility between the two, WPF will be getting the VSM later this year more than likely with .NET 3.5 SP1.

An ongoing area of particular interest to me (and this blog) will be the the Networking Improvements, the support for Duplex Communication (Server Push) has made it into Beta 2 with the System.ServiceModel.PollingDuplex.dll assembly amongst others.  Two copies of this assembly come with the Beta 2 SDK, one copy under the %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Client folder and another under the uncharacteristically named ‘Evaluation’ folder at %ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Libraries\Server, so maybe this support only just made it in…

Posted in Silverlight | Tagged: , , | 3 Comments »