views:

247

answers:

1

Hi there,

I've been given a custom Silverlight control to use, and everytime I open it up in Blend, get the "The DOM/scripting bridge is disabled" error.

Looking in the control's source code, I can see calls to

public override void OnApplyTemplate()
    {
           ...
   HtmlPage.Window.Invoke("GetPrimaryGradStart").ToString()

which I'm guessing might be the problem. Any ideas about what I can do, or am I back to pure XAML?

cheers

Toby

+2  A: 

Hi there,

usually (i.e. when a Silverlight app is embedded in an HTML page) one has to set the "enablehtmlaccess" parameter to true for the app via HTML or JavaScript, because otherwise calls like HtmlPage.Window.Invoke are not allowed (and throw an exception). So I guess the problem is that blend does/can not set that parameter and only shows that message instead. If you have control over the code, you could add a condition that checks whether you are in design mode or runtime mode using DesignerProperties.IsInDesignTool, for example:

if (!DesignerProperties.IsInDesignTool)
{
    // Do the "evil stuff"
    HtmlPage.Window.Invoke("GetPrimaryGradStart");
}

Hope that helps.

Cheers, Alex

EDIT: If it does help, you might also want to add some pre-compiler directives to your code so that you won't have those design tool stuff statements in your production app:

#if !RELEASE
if (!DesignerProperties.IsInDesignTool)
#endif
HtmlPage.Window.Invoke("GetPrimaryGradStart");
alexander.biskop
that's the ticket! It's actually calling some javascript to return a colour from a CSS style, so I now just check on the DesignerProperties.IsInDesignTool and use a default colour insteadcheers
TobyEvans