DCSIMG
JavaScript - Alex Golesh's Blog About Silverlight Development

Browse by Tags

All Tags » JavaScript (RSS)

Meet me at BUILD

BUILD/Windows approaching fast. As previous years with PDC, also this time SELA sends around 20 top experts to BUILD . I will be there also If you want to meet me or someone of other SELA experts to discuss some exciting news I’m sure we are going to get at BUILD (or just say “Hi”) feel free to send me a tweet @DevCorner.   See you at BUILD, Alex

Silverlight Tip: Object Creation via Silverlight.js – IE8 & FireFox tweak

Yesterday, when I arrive to the office my colleague (same one from this post) waited for me at the entry with new question/problem. That’s what I heard: - Hi Alex. I have a problem with my Silverlight application under FireFox – it is not being displayed on page! In IE(7) everything works fine, and in the FF is event not shown… :( - Well – I said – let’s see… I’ve got the sources from the company source server, launched the application on my machine IE(8) and got very “wired” sized application and...

Silverlight Quick Tip: How to resize window from Silverlight

One of my colleagues asked me if it is possible to resize the Browser Window from within Silverlight application. Well, my answer was: “everything what is possible to do from JavaScript is possible to do from Silverlight”. Here is sample code how to do it in case someone else is also looking for the solution: if ( HtmlPage .BrowserInformation.UserAgent.ToLower().IndexOf( "chrome" ) < 0) { HtmlPage .Window.Invoke( "moveTo" , new object [] { 100, 100 }); HtmlPage .Window.Invoke...

Silverlight Tip: How to Inject and Execute JavaScript Function(s) on-the-fly from Silverlight

Today I’ve been asked by colleague how to inject and execute JavaScript functionality from Silverlight application to the HTML DOM of hosting page. Well, things are pretty easy. First we need to get JavaScript from somewhere. In colleague's case it was an embedded resource, in my sample I’ll use TextBox to accept the script code. Also I’ll accept function name and parameters from UI. From here we have two approaches: to Eval the function code or to create “Script” element dynamically. First approach...

Quick Silverlight Tips: Control Reflection, Control Properties Data Binding, Window Title and Status Bar text (IE only)

Well it was pretty long time since my last post here… I was busy, mostly doing consulting… Now the pressure is eased of alittle, so I hope to write here more.   During this time I heard a couple of questions from clients which were pretty easy to solve but possibly still not obvious. My first tip today will be about “how to produce reflection under text box” and “emulate PropertyBinding” (like it worked at WPF) To produce reflection (in case of TextBox) I built Vertical StackPanel with desired...

Quick Silverlight Tip: Creating/Destroying Silverlight 2 Object dynamically

One of my clients asked me how to create and show (and then destroy) Silverlight application on the fly. Here is very fast solution, which allows such an object to be created and destroyed. First, we (still) need to have some DIV which will hold the object. Here is my sample page HTML: 1: < body > 2: <!-- Runtime errors from Silverlight will be displayed here. 3: This will contain debugging information and should be removed or hidden when debugging is completed --> 4: < div id ='errorLocation'...

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

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

Silverlight application performance - refresh rate & CPU usage

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

Silverlight Tip: How to reflect ScriptObject content in runtime

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

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

Quick Silverlight Tip: Initialization Parameters

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

Quick Tip: Silverlight Integration within HTML content

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

Quick Tip: Isolated Storage in Silverlight 2 Beta 2

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

My WDC Presentation

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

How To Handle RightClick Mouse Event in Silverlight - Take 2

Some time ago, I've posted article about how to handle RightClick mouse event in Silverlight . At the time of the post, there were Silverlight 1.1 alpha. Now we at Silverlight 2 Beta 1 (and approaching Beta 2 sometime soon), and here is update to my previous article. This update is closely related to previous post , thus this one will have only changes... Here we go. First of all, my XAML page is still very simple 1: < UserControl x:Class ="RightClickSilverlight.Page" 2: xmlns ="http...
More Posts Next page »