Creating Pop-up window in XAML Browser Application

Note: Requires Microsoft Visual Studio 2008(C#) to debug / run.


Download the project files (Zip) - 85 KB


screen shot


Background:


You might know that Windows Presentation Foundation (WPF) introduces a new application type: XAML Browser Applications (XBAPs; earlier known as Web Browser Applications [WBAs]) which are online-only applications and run in the browser and are not installed. These applications execute in a security sandbox and harness the power of the WPF platform on the Web. Due to sand-boxing, this kind of application has limited-privileges and do not allow us to use WPF Window control.


This sample demonstrates an approach to show a pop-up window like control in XBAP application.


Implementation:


I have used the Popup Class in System.Windows.Controls.Primitives namespace of .NET framework 3.5 to represent a pop-up window that has user defined content. A Popup control displays content in a separate window that floats over an application. You can specify the position of a Popup relative to a control, the mouse, or the screen by using the PlacementTarget, Placement, PlacementRectangle, HorizontalOffset, and VerticalOffset properties.


In this sample, I have created a "PopUpControl" UserControl which draws the content of the pop-up window. Then I've written the following XAML code snippet to define the Popup class with in the main page.


code

By default its IsOpen property is set to False. On the "Inquire" button click event we have to set it to True. And it will display content in a separate window that floats over the main application page. When the user closes the pop-up window, we have to set it back to False.


In this sample, I have also shown an example on how to populate ListView control dynamically.


References:


1. Windows Presentation Foundation Security Sandbox:
http://msdn.microsoft.com/en-us/library/aa480229.aspx

2. Popup Class:
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup.aspx


History:



  • 11th Nov, 2009: Initial version.


Attachments

  • code (34699-111235-code.bmp)
  • screen (34699-111236-screen.bmp)
  • Download VS 2008 Project (34699-111710-XBAPPopUpWindow.zip)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: