Search code examples
c#buttonoverlaysilverlight-5.0childwindow

Silverlight 5: Create an overlay above child window


I want to add a custom loading indicator when a button on child window is clicked. The loading overlay should appear above the whole screen. For this, I have created an overlay in rootvisual page which is hidden initially. When a button on child window is clicked, I make that overlay visible, but the problem is, the overlay appears behind the child window. What should I do to make it visible above child window? Is there any approach better than one I am using?


Solution

  • I could create overlay without having to use something like Modal Window or another Child Window. I created one div occupying whole screen and containing loading.gif. The div is hidden initially (display:none) While I want to show loading indicator, I make that div visible through Silverlight code as shown below:

    HtmlElement div = HtmlPage.Document.GetElementById("loading-overlay");
    div.RemoveStyleAttribute("display");
    

    To hide the loading indicator again,

    HtmlElement div = HtmlPage.Document.GetElementById("loading-overlay");
    div.SetStyleAttribute("display", "none");