110,539
社区成员
发帖
与我相关
我的任务
分享
namespace WpfBrowserApplication1
{
/// <summary>
/// Interaction logic for Page1.xaml
/// </summary>
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
MessagePopup.Show(this,"hello");
}
}
}
namespace WpfBrowserApplication1
{
public sealed class MessagePopup
{
public static void Show(UIElement parent, string message)
{
Popup window = new Popup();
StackPanel sp = new StackPanel { Margin = new Thickness(5) };
sp.Children.Add(new TextBlock { Text = message });
Button newButton = new Button { Content = window.Parent.ToString() };
newButton.Click += delegate { window.IsOpen = false; parent.IsEnabled = true; };
sp.Children.Add(newButton);
sp.Children.Add(new Slider { Minimum = 0, Maximum = 50, Value = 25, Width = 100 });
window.Child = new Border
{
Background = Brushes.White,
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(2),
Child = sp
};
window.PlacementTarget = parent;
window.Placement = PlacementMode.Center;
window.IsOpen = true;
parent.IsEnabled = false;
}
}
}