0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その534

Posted at

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

wpfを1ファイルで書け。

方針

  • xamlを使わない。

サンプルコード


using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;


class Wpf {
	[STAThread]
	public static void Main() {
		Application app = new Application();
		Window wnd = new Window();
		Canvas cnvs = new Canvas();
		Button button1 = new Button();
		TextBlock txt1 = new TextBlock();

		txt1.FontSize = 14;
		txt1.Text = "Hello World!";
		Canvas.SetTop(txt1, 100);
		Canvas.SetLeft(txt1, 10);
		cnvs.Children.Add(txt1);
		wnd.Title = "Wpf";
		wnd.Width = 400;
		wnd.Height = 400;
		button1.Content = "test";
		Canvas.SetLeft(button1, 50);
		Canvas.SetTop(button1, 50);
		button1.Click += (sender, e) => {
			MessageBox.Show("hello, world");
		};
		cnvs.Children.Add(button1);
		wnd.Content = cnvs;
		app.Run(wnd);
	}
}





実行結果

image.png

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?