.NET|--WPF|--如何使用LINQPad创建一个WPF示例

1.安装包管理器


# 搜索框内需要填入↓

"id=Microsoft.NETCore.App"
"id=Microsoft.WindowsDesktop.App.Ref"

2.代码

void Main()
{
	var app = new System.Windows.Application();
	var mainWindow = new System.Windows.Window
	{
		Title = "Simple WPF Program",
		Width = 300,
		Height = 200,
		WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen
	};

	var button = new System.Windows.Controls.Button
	{
		Content = "Click Me!",
		HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
		VerticalAlignment = System.Windows.VerticalAlignment.Center
	};
	button.Click += (sender, e) => System.Windows.MessageBox.Show("Button Clicked!");

	mainWindow.Content = button;

	app.Run(mainWindow);
}

3.效果

posted @ 2024-05-30 13:00  zh89233  阅读(33)  评论(0编辑  收藏  举报