Page view counter

Did You Know That... if you want your Silverlight control to have a transparent background, you must set isWindowless to true

As noted in an earlier Tip of the Day, typically you do not want a windowless Silverlight control, as there is a high performance price in rendering windowless controls.

However, if you wish to set the background to be transparent, you must remember to set the isWindowless property to true, or the entire Silverlight control will be rendered as solid black.

Both of these properties are set in createObjectEx in default.html.js,

Silverlight.createObjectEx({
    source: 'Scene.xaml',
    parentElement: document.getElementById('SilverlightPlugInHost'),
    id: 'SilverlightPlugIn',
    properties: {
        width: '200',
        height: '200',
        background:'transparent',
         isWindowless: 'true',
        version: '1.0'
    },

By setting the Silverlight control as shown, and then adding a rectangle to your XAML with no fill color, you can see that the Silverlight control is transparent,

IsWindowlessTrue

If however you return to the declaration of the Silverlight control, and change only the isWindowless parameter to false, the entire control is rendered in solid black

IsWindowlessFalse

kick it on DotNetKicks.com
Published 11 January 2008 10:00 AM by jesseliberty

Comments

# DotNetKicks.com said on 11 January, 2008 10:15 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# BenHayat said on 11 January, 2008 12:13 PM

I think you should also mention that by setting to "isWindowless" to true, there will be a performance hit while the control is being rendered. Which in 1.0 and JS running in interpreter mode, can slow things down a lot!

Just my two cents!

# jesseliberty said on 11 January, 2008 12:48 PM

Ben, I don't mean to be defensive, but I do mention that in both posts... "as there is a high performance price in rendering windowless controls"  

It would, however, be interesting to find out if anyone has benchmarked the actual performance cost. :-)

# swildermuth said on 11 January, 2008 12:54 PM

Jesse,

Your comment I think is right on the mark.  I when I teach my class, I mention that isWindowless is a cost of performance but what this really means is hard to quantify (you use the words "high performance price", but that is still ambiguous.  Do you know if anyone on the team can offer any real advice on isWindowless?  Is it a bigger issue with 1.0 than 2.0, etc.?  

# BenHayat said on 11 January, 2008 01:27 PM

Jesse, my apology that I missed your statement. And my intention was just to make sure your blogs are always perfect! ;-)

# jesseliberty said on 14 January, 2008 12:57 PM

Ben,

Never fear to make such corrections; even if you are not right, better that you make the comment and we discuss than that you hold back.

Thanks again.

-j

# Jon Galloway said on 15 February, 2008 04:00 AM

Silverlight 1.0 has no intrinsic controls. Forget about dropdowns and sliders, Silverlight 1.0 doesn

# nagina said on 06 March, 2008 04:53 AM

Hi Jesse,

I have some question regarding isWindowless property.

In my aspx page i am setting the background to be picture by using css property.

.body1

{

background-image: url(../images/background/bg2.jpg);

margin:0;

    padding: 0px;

    height:100%;

    border:none;

    overflow: hidden;

}

I want my silverlight to have the same background as my page or to be transparent

but, I must to set the isWindowless: to 'false', because either way  i have display problems (on media center windows).

I tried to set the bakground by setting background:document.body.style.backgroundColor

and tried to set it transparent(and alpha colors) and it did not helped either.

Is there any way to set the silverlight background to be transparent and leave the isWindowless to be 'false'or maybe to set the background of silverlight to be picture too?

Thanks

# ClosDesign said on 24 March, 2009 05:37 PM

Is there a working example of any of this live on the internet?????

Everywhere I look is code but not working examples.