1
1

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の作法 その536

Last updated at Posted at 2024-11-18

概要

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

練習問題

wpfを1ファイルで書け。

方針

  • xamlを使わない。
  • Windowクラスを使う。

参考にしたページ

サンプルコード


using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;

namespace Wpf
{
	public partial class MainWindow: Window {
		public MainWindow() {
			var clock = new TextBlock();
			clock.FontSize = 30;
			var timer = new DispatcherTimer();
			timer.Tick += (sender, e) => {
				var dt = DateTime.Now;
				clock.Text = dt.ToString();
			};
			timer.Interval = TimeSpan.FromSeconds(1);
			timer.Start();
			Title = "Clock";
			Width = 320;
			Height = 100;
			Content = clock;
		}
	}
	class MainApp {
		[STAThread]
		public static void Main() {
			MainWindow mwnd = new MainWindow();
			Application app = new Application();
			app.Run(mwnd);
		}
	}
}




実行結果

image.png

以上。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?