Silverlight Tip: How to reflect ScriptObject content in runtime

Tuesday, July 15, 2008

Today I want to show how Silverlight application could "understand" which objects form HTML DOM from hosting page it deals with. The minute before I start, let me show why many of Silverlight developers need it. Lets assume we have some simple HTML/ASPX page, with some JavaScript functionality and JavaScript objects, like follows: 1: <html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;"> 2: <head runat="server"> 3: <title>Test Page For ScriptReflector</title> 4: 5: <SCRIPT language="JavaScript"> 1: ...

Quick Silverlight Tip: Communicating between two Silverlight objects on a single page

Thursday, July 10, 2008

Today I'll show how two Silverlight objects (Silverlight applications) could communicate while been hosted on one page. Earlier today I've seen some blog post by Joel Neubeck about Silverlight objects communication. The way Joel does it is pretty traditional, by providing some JavaScript functionality on host page to communicate with each Silverlight application. I'll show slightly different approach: each Silverlight application will communicate directly with another (giving the fact, that the IDs of Silverlight applications on page could be provided to each application with initialization parameters. More info about initialization parameters for Silverlight application could be found here). For...

Quick Tip: Silverlight Integration within HTML content

Thursday, June 19, 2008

Couple of days ago I've got question, how Silverlight content could been integrated/overlapped by some HTML/AJAX content. The samples I've received produced following behavior - When clicking on hyperlink, it opens "modal pop-up" but Silverlight control is floating over it:   Another sample: When clicking on "Click Here" button HTML "window" being placed behind Silverlight control: Now the quick tip: When you need to make layering, positioning, etc. integration of your Silverlight content and HTML content you have to define "Windowless" parameter for Silverlight object: <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/AjaxModal_SL.xap" Width="600px" Height="600px" Windowless="true" /> or <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2"...

Path.Data Dependency Property Initialization from String – Take 2

Wednesday, June 18, 2008

Day or to ago, I've blogged how to initialize Path.Data property in Silvelright 2 Beta 2 from string. In this post I've mention, that probably the best and the right way to do it is develop functionality similar to WPF's PathFigureCollectionConverter object. Now it exists: the porting of PathFigureCollectionConverter functionality for Silverlight 2 Beta 2 in my CodePlex project. Here is usage sample (just add reference to your project): XAML <Path x:Name="path" Canvas.Left="10" Canvas.Top="30" Stroke="Black" Height="200" Width="200"/> CSharp PathConverter.StringToPathGeometryConverter conv = new PathConverter.StringToPathGeometryConverter(); PathGeometry pathData = conv.Convert(pathString); path.SetValue(Path.DataProperty, pathData); The result (path string was "M 16.749,115.917C 16.749,85.5106 58.2626,70.0341 84.4816,68.9416C 110.701,67.8491 136.028,70.1342 147.844,76.0426C 153.853,79.0469 154.945,80.9587...

Path.Data Dependency Property Initialization From String

Monday, June 16, 2008

In Silverlight 2 Beta 1 I used to build dynamic UI with drawing portions. For example, I used to draw Path dynamically like in following example: Path myPath = new Path(); myPath.SetValue(Path.DataProperty, "M 50,50 L 50,100 L 100,100 L 100,50 L 50,50 Z"); myPath.SetValue(Path.NameProperty, "myPath"); myPath.Width = 100; myPath.Height = 100; myPath.Fill = new SolidColorBrush(Colors.Black); LayoutRoot.Children.Add(myPath); This gave me nice rectangle... Everything was fine, until I start to port my project to Silverlight 2 Beta 2. After fixing all known stuff, I finally executed the application and in the moment I expected to get some nice Path being drawn I've got exception: What happened? Why? It...

Quick Tip: Isolated Storage in Silverlight 2 Beta 2

Sunday, June 8, 2008

One of changes in new Silverlight 2 Beta 2, is new "Silverlight Configuration" screen.   Now we can take control over DRM and Application Storage. Application storage screen controls isolated storage data and quotas for application being used it:   But what could be stored in this storage? What if default quota (1Mb) is not enough? Could it been changed?   The isolated storage could store files and application settings. Working with isolated storage is pretty much like with file system: First of all we need to get IsolatedStorage for application: var store = IsolatedStorageFile.GetUserStoreForApplication() Then, we...

Silverlight 2 Beta 2 available

Saturday, June 7, 2008

As was announced earlier this week at TechEd 2008 in Orlando, new Beta 2 for Silverligth 2 has arrived! Here download links: Runtime only Silverlight 2 Beta 2 Tools for Visual Studio 2008 (includes Silverlight SDK, Developers runtime, project templates in single chained installation) Belnd 2.5 June preview Deep Zoom Composer Beta 2 Many samples and tutorial videos here   Enjoy, Alex

Visual Studio 2008 SP1 Beta & .NET 3.5 SP1 Beta are available

Tuesday, May 13, 2008

The SP1 Beta for Visual Studio 2008 and .NET 3.5 has arrived. The beta of service pack holds a few improvements. There is also WPF speed improvements with this upcoming service pack. Tim Sneath has very detail information at his blog about this release here. Download links: VS 2008 SP1: http://download.microsoft.com/download/7/3/8/7382EA08-4DD6-4134-9B92-8585A5B07973/VS90sp1-KB945140-ENU.exe .NET 3.5 SP1: http://download.microsoft.com/download/8/f/c/8fc1fe13-55de-4bf5-b43e-375daf01452e/dotNetFx35setup.exe Enjoy, Alex

ColorConverter in Silverlight 2

Tuesday, April 29, 2008

Do you miss ColorConverter class in Silverlight? I do... Really... I today bind Background property to some color value received from JavaScript. JavaScript provides a value in string format, something like "#FFDEDEDE". The way to bind to background property is to prepare SolidColorBrush, and the way to SolidColrBrush lies via Color. And how one can make Color object from string? In full .NET framework there is a handy class, called ColorConverter which provides such functionality... In Silverlight System.Drawing doesn't exists, and so ColorConverter... And so my plan to convert string to System.Windows.Media.Color was ruined... To solve this I created class,...