DCSIMG
May 2009 - Posts - Alex Golesh's Blog About Silverlight Development

May 2009 - Posts

Silverlight 3 Release Date

According to this resource Silverlight 3 and Blend 3 will be released 10 July 2009.

Prepare yourself to move to the new version, prepare for breaking changes and migration from Beta to RTW :)

 

More to come, stay tuned!

Alex

Silverlight & Visual Studio 2010 Beta

As you probably know, Visual Studio 2010 Beta 1 was released to MSDN subscribers and soon will be released to general public here.

What is new in this release for Silverlight developers?

First of all – Silverlight is a first class citizen in this release, like WPF for example.

image

More good news - now we will be able to create/manage both version of Silverlight projects (2 and 3)!

When you choosing to create a new Silverlight projects, you will be prompted with dialog which allows to select the version of the technology:

image

Even after creating the project, you still could add new Silverlight project to the solution and once again you will be able to choose the version:

image

The created projects has correct references to the selected versions:

Silverlight 2

Silverlight 2

Silverlight 3

Silverllight 3

Visual studio will create Test pages accordingly:

Silverlight 2

Silverlight 2

Silverlight 3

Silverlight 3

Both of projects has same default compilation target placement:

image

The project properties screen will give you the chance to change target compilation version

image

Same controls could be used as references and as linked sources:

image

Properties editor with element preview and has many improvements (like brush visualization, data binding helper, etc.):

image

image

...and the best of all – the editor is fully interactive (for both versions)!

image

The Beta could be installed side by side with Visual Studio 2008.

Some things you should know, when using this Beta – there are some performance issues with the Cider (UI editor) and some bugs with XAML editor (like ability to use/compile Silverlight 3 features within Silverlight 2 projects).

image

Also I experienced some freezes/crushes of environment.

Generally – the Beta is pretty stable and worth to download and try!

 

More Silverlight 3 stuff to come! Stay tuned…

 

Enjoy,

Alex

Silverlight Quick Tip: How to change Tab Items order

I’ve got a question from my colleague about how he could change the order of Tab Items according to some business logic.

When adding the TabItem to the Tab control dynamically (from code behind for example) the TabItems will be added in the order they added. Here is the simple solution of hot change the order of already added tabs.

In my case I have simple XAML with Tab Control:

<controls:TabControl Width="400" Height="200" x:Name="tabs" Margin="5">
  <controls:TabItem Header="Tab #1">
    <controls:TabItem.Content>
      ...
    </controls:TabItem.Content>
  </controls:TabItem>

  <controls:TabItem Header="Tab #2">
    <controls:TabItem.Content>
      ...
    </controls:TabItem.Content>
  </controls:TabItem>

  <controls:TabItem Header="Tab #3">
    <controls:TabItem.Content>
      ...
    </controls:TabItem.Content>
  </controls:TabItem>
</controls:TabControl>

Here is simple code snippet to change the tab order:

TabItem item = tabs.Items[Tab_Index_Which_Should_Be_Moved] as TabItem;

tabs.Items.Remove(item);
tabs.Items.Insert(Index_Of_New_Tab_Location, item);

That’s it :) Very simple…

This will work for both Silverlight 2 and Silverlight 3.

 

Enjoy,

Alex

 

p.s. I prepared some cool Silverlight 3 (post-Beta) related posts and they will be released at the moment I’ll be able to do it. Stay tuned!

Silverlight 3 at WDC (03 May 2009) – Thanks for all participants!

image

Thank you all, who participated yesterday at Silverlight 3 Overview for WDC (Microsoft Israel offices). I uploaded printouts of the slides, presented during the session could download them for a reference.

I’m really interesting within your feedback (leave comments) in order for me to be able to enhance it for future events.

PowerPoint printouts here.

 

Thanks and hope to see you again next time!

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 on FF it was indeed not shown. When I launched the same application from the Visual Studio created *Test.html page everything was fine (both IE8 and FF).

Here is small application screenshots I’ve build during investigation:

IE8:

image

FF:

image

While investigating this issue I’ve spotted, that my colleague creates and instance of Silverlight object with “createObjectEx” function from Silverlight.js, while VS2008 creates it directly on page. It was clear for me that differences is somewhere there…

Let’s see the object being created by VS:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
      width="100%" height="100%">
      <param name="source" value="ClientBin/SilverlightApplication47.xap" />
      <param name="onerror" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="3.0.40307.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=141205" style="text-decoration: none;">
        <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
          style="border-style: none" />
      </a>
</object>

Now the object as it being placed inside “innerHTL” property of parentElement object (received as a parameter):

<object type="application/x-silverlight" data="data:application/x-silverlight,"
  id="Xaml1" width="100%" height="100%">
  <param name="background" value="white" />
  <param name="enableHtmlAccess" value="true" />
  <param name="source" value="ClientBin&#47;SilverlightApplication47.xap" />
</object>

The differences is obvious, and I thought that type & data does the “magic” and I’ve tweaked Silverlight.js to produce exactly the same object. But I was wrong… After digging some time in internet I’ve got some side note about FF HTML width/height eveluation/inheritance in runtime (for elements being added/changed as a result of JavaScript execution). I assumed, that IE8 behave exactly like FF in this case (and as it turns that it really does), so I finally found the solution I’d like to share.

When you are creating your Silverlight object with the script you have to specify width/height for parent DIV element:

So, original HTML code:

<divid="SilverlightControlHost"style="left: 0px; top: 0px;">
  <scripttype="text/javascript"language="javascript">
   
createSL();
  </script>
</
div>

turns to:

<div id="SilverlightControlHost" style="left: 0px; top: 0px; width:640px; height:730px;">
<script type="text/javascript" language="javascript">
    createSL();
  </script>
</div>

This caused to my app to look desired way under IE8:

image

and under FF:

image

 

To conclude – when you have to use functions from Silvelright.js don’t forget to specify absolute size to containing DIV element, or create Silverlight <OBJECT> which doesn’t have those issues.

 

Hope this will help to solve the problem if it will appear to someone :)

 

Enjoy,

Alex