Quick Silverlight Tip: Initialization Parameters

June 29, 2008

The scenario: you developing Silverlight application, and you need to pass some parameter inside - for example to define which page will be shown, or to pass user credentials, after he already logged-in in previous non-Silverlight part of application. So, ho you could do it? The answer is pretty simple - "initParams" in Silverlight object construction. The parameters could be named, and not named. Named parameters example: <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2" width="100%" height="100%"> <param name="source" value="ClientBin/InitParams.xap"/> <param name="onerror" value="onSilverlightError" /> ...

Quick Tip: Silverlight Integration within HTML content

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

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

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

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

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

My WDC Presentation

June 2, 2008

Yesterday (1 June 2008) I did a Silverlight overview at local WDC (Web Developers Community) monthly meeting. Thanks for all participants! Presentation slides could be found here. Democode here (basics) and here (media player, source code only. Video file will be posted later because of its size).   Enjoy, Alex