Quick Silverlight Tip: Silverlight Events in JavaScript and JavaScript Events in Silverlight

July 28, 2008

Lately I've been asked couple of times about catching managed events in JavaScript and catching JavaScript events in Silverlight managed code. In fact it is very easy, but seems not so obvious... Here it goes. To catch JavaScript event in Silverlight managed code, all your application need to do is to "attach" to event from some HtmlElement you have on hosting page and define some managed EventHandler to handle the event. Sample page as it was auto generated by Visual Studio 2008, MyApplicaitionTestPage.html. All I added to this test case is HTML button: 1: <input...

Quick Silverlight Tip: "InitializeError #2103 – Invalid or malformed application" what is it and how to deal with it?

July 22, 2008

Today I've seen very strange and unpleasant error while trying to run some freshly created Silverlight application. It said: Code# 2103 Invalid or malformed application: Check manifest Fast search by popular search engines gave me this and this places, but everything mentioned there I've already knew or tried before... So what is it? Let's see what it was and how it was solved. Let's reproduce it.   I'm creating new Silverlight 2 project, compiled it it works... My simplest project looks like follows (every button click just adds "!" to Button.Content):   Everything works fine, until I decided...

Silverlight & Streaming Media

July 20, 2008

Lately I'm getting a lot of questions what could be done with Silverlight in in terms of work with streaming media. Today I'll show what could be done. I've built very simple media player based on MediaElement object and prepared some stream to use in my application. The major focus of this post it to briefly show what could be done with stream in Silverlight and not how specifically do it. I'll be glad to answer any specific questions there will be any. First about the stream. I've tried to find on my laptop some media, which will...

Silverlight application performance – refresh rate & CPU usage

July 17, 2008

You just wrote great Silverlight application? How about CPU usage? Do you have pretty static application UI and it still consumes 25-30% of your CPU? Probably you have to control how fast Silverlight should redraw the UI. To do it, you need to specify MaxFrameRate property in object initialization, like follows: 1: <asp:Silverlight ID="Xaml1" runat="server" 2: Source="~/ClientBin/ShowFPS.xap" 3: MinimumVersion="2.0.30523" 4: Width="100%" Height="100%" ...

Silverlight Tip: How to reflect ScriptObject content in runtime

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

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...

My Presentation at IDF Developers Forum

July 6, 2008

I will present at next IDF developers forum, which will take a place in Tel-Aviv, 27/07/2008. If you are an IDF developer, interested in Silverlight and/or want to get some practical tips & tricks about .NET reflection you more than welcome.   See you there, Alex