ウインドウの現在位置なんて、遊びくらいでしか触らないでしょうけどね。
これを書き換えると現在位置を変えられるの。わかった?
乱数で、勝手にウインドウを動かしてみましょうか。
Random cr292 = new System.Random(); public MainWindow() { InitializeComponent();
DispatcherTimer dt = new DispatcherTimer(); dt.Interval = new TimeSpan(0, 0, 0,0,100); dt.Tick += new EventHandler(dt_Tick); dt.Start(); } void dt_Tick(object sender, EventArgs e) { // 移動距離 int k = cr292.Next(1, 4); // 0 以上 512 未満の乱数を取得する int ii = cr292.Next(0,8); // 0:↑ 1:/ 2:→ 3:\ 4:↓ 5:/ 6:← 7:\ switch (ii) { case 0: this.Top -= k; break; case 1: this.Top -= k;this.Left += k; break; case 2: this.Left += k; break; case 3: this.Top += k;this.Left += k; break; case 4: this.Top += k; break; case 5: this.Top += k;this.Left -= k; break; case 6: this.Left -= k; break; case 7: this.Top -= k; this.Left -= k; break; default: break; } }
うん、こんなところね。