Creating a Dialog from Silverlight

A simple piece of code for Creating a Dialog from Silverlight.

private void button1_Click(object sender, RoutedEventArgs e)
{
ChildWindow flotwin = new ChildWindow(); flotwin.Title = “Blue Window”;
System.Windows.Controls.Primitives.Popup popup = new System.Windows.Controls.Primitives.Popup();

flotwin.MouseLeftButtonDown += (a, x) =>
{

this.LayoutRoot.Children.Remove(popup);
this.LayoutRoot.Children.Add(popup);
popup.IsOpen = true;
};

StackPanel stackPanel = new StackPanel()
{
Height = 600,
Width = 800
};

WebBrowser browswer = new WebBrowser();
browswer.Width = 800;
browswer.Height = 600;
browswer.Navigate(new Uri(http://MyServer/));
stackPanel.Children.Add(browswer);

flotwin.Content = stackPanel;
flotwin.Closing += (ss, ee) =>
{
popup.IsOpen = false;
};

popup.Child = flotwin;
popup.IsOpen = true;

LayoutRoot.Children.Add(popup);
}

Special Thank to Usama Wahab Khan
http://usamawahabkhan.blogspot.com/2010/06/flotable-window-deom.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s