Creating a Popup in a UserControl

In this example, you'll create the popup's content in a separate user control and use an instance of that control as the content of the popup.  Note that the application you'll create will look just like the application created in the Popup for Windows Phone Quick Start but the content of the popup is handled differently.

Complete the following steps:

1.   Right-click the project name in the Solution Explorer and select Add | New Item.

2.   In the Add New Item dialog box, choose Windows Phone User Control, name the control "C1PopupUserControl", and click Add.

3.   Edit the UserControl's markup so it appears similar to the following:

      XAML

This is the content that will be used in the C1Popup control. Note that it is the same content used in the Popup for Windows Phone Quick Start.

4.   Return to the MainPage.xaml source view. Add markup to the main GridContentPanel so it appears like the following:

      XAML

5.   Select View | Code to switch to Code View and add the btnOpen_Click event handler so the code looks like the following:

      C#

This markup will initialize the popup wen the button on the main page is selected.

What You've Accomplished

In this topic you created a UserControl to house the C1Popup control's content. Note that you'd need to set the Content property to the control.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.