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

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen Pluralsight & LinkedIn Learning courses. He was a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in z Silverlight Archives and tagged . Bookmark the permalink.