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 Friday, January 11, 2008 10:00 AM by jesseliberty

Comments

# isWindowless and transparent background

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

Friday, January 11, 2008 10:15 AM by DotNetKicks.com

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

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!

Friday, January 11, 2008 12:13 PM by BenHayat

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

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

Friday, January 11, 2008 12:48 PM by jesseliberty

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

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

Friday, January 11, 2008 12:54 PM by swildermuth

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

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

Friday, January 11, 2008 1:27 PM by BenHayat

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

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

Monday, January 14, 2008 12:57 PM by jesseliberty

# Using Windowless Silverlight Controls To Blend HTML and Silverlight Elements

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

Friday, February 15, 2008 4:00 AM by Jon Galloway

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

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

Thursday, March 06, 2008 4:53 AM by nagina

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

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

Everywhere I look is code but not working examples.

Tuesday, March 24, 2009 5:37 PM by ClosDesign