1: void OnClick(object sender, EventArgs e)
2: {
3: Popup window = new Popup();
4:
5: StackPanel sp = new StackPanel { Margin = new Thickness(5) };
6: sp.Children.Add(new TextBlock { Text = "Hi from a popup" });
7: Button newButton = new Button { Content = "Another button" };
8: newButton.Click += delegate { window.IsOpen = false; };
9: sp.Children.Add(newButton);
10: sp.Children.Add(new Slider { Minimum = 0, Maximum = 50, Value = 25, Width = 100 });
11:
12: window.Child = new Border { Background = Brushes.White, BorderBrush = Brushes.Black, BorderThickness = new Thickness(2), Child = sp };
13: window.PlacementTarget = this;
14: window.Placement = PlacementMode.Center;
15:
16: window.IsOpen = true;
17: }
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.