Canarys | IT Services


How to add Overlay in Windows phone 8


Windows Phone is windows mobile operating system from Microsoft.

In my project, there was a requirement of Overlay panel whenever the data is requested from server (i.e., when task takes some time to execute).

Here, I am going to show you a sample example of using overlay in windows phone project.

Find the sample solution here

Overlay, is it a control or a property?

No, the overlay is not a control or a property but it is a process which can be achieved using Popup a Class present in Windows Phone 8 with namespace (System.Windows.Controls.Primitives) and UserControl as Popup.

Steps required

1. Right click in the application -> Select Add -> Select New Item-> Select Windows Phone User control and name it as Overlay.xaml

Step 1


2. Add the below mentioned code in Overlay.xaml.cs replace for constructor

Usercontrol Example

Usercontrol design view

        //usercontrol constructor
        public Overlay()
            this.LayoutRoot.Height = Application.Current.Host.Content.ActualHeight;
            this.LayoutRoot.Width = Application.Current.Host.Content.ActualWidth;
            SystemTray.IsVisible = false; //to hide system tray

3. Add a property below mentioned into the MainPage.xaml (your required form)

  private Popup popup; //property which make usercontrol as  popup

4. Add the below mentioned into MainPage.xaml constructor

        //Page Constructor
        public MainPage()
            this.popup = new Popup();

5. Call the method OpenOverlay() on any event to open overlay and CloseOverlay() when close is required.

        /// Opens the usercontrol which acts as overlay
        private void OpenOverLay()
            this.LayoutRoot.Opacity = 0.2;
            OverLay ovr = new OverLay();
            this.popup.Child = ovr;
            this.popup.IsOpen = true;

        /// Closes the usercontrol which acts as overlay
        private void CloseOverLay()
            popup.IsOpen = false;
            this.LayoutRoot.Opacity = 1.0;

Note :  The sample shown is with progress bar and TextBlock.
 I have tried to use spinner inside overlay as Loader image. Please, find the design sample OverlaySpinner.xaml 
Usercontrol with spinner
Download the sample solution 

Leave a Reply

Your email address will not be published. Required fields are marked *

Reach Us

With Canarys,
Let’s Plan. Grow. Strive. Succeed.