回答編集履歴

1

見直しキャンペーン中

2023/07/29 10:31

投稿

TN8001
TN8001

スコア9326

test CHANGED
@@ -1,49 +1,23 @@
1
1
  `GetValue`の使い方が間違っています。
2
2
 
3
-
4
-
5
3
  これですと`this.GetValue(Grid.ColumnProperty)`という意味になり、`MainWindow`の`Grid.Column`を取得します。
6
-
7
4
  `MainWindow`には`Grid.Column`を付けることはないでしょうから、常に`0`(規定値)が返ってきます。
8
5
 
9
-
10
-
11
6
  `Rectangle`の`GetValue`を呼ぶ必要があります(if内も同じ)
12
-
13
- ```C#
7
+ ```cs
14
-
15
8
  clPoint_x = rec.GetValue(Grid.ColumnProperty);
16
-
17
9
  clPoint_y = rec.GetValue(Grid.RowProperty);
18
-
19
10
  ```
20
-
21
11
  [DependencyObject.GetValue(DependencyProperty) メソッド (System.Windows) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.dependencyobject.getvalue?view=netframework-4.7.2#System_Windows_DependencyObject_GetValue_System_Windows_DependencyProperty_)
22
12
 
23
-
24
-
25
13
  あるいは`Grid.GetColumn`・`Grid.GetRow`で取得すると、`int`で返ってくるので楽です。
26
-
27
- ```C#
14
+ ```cs
28
-
29
15
  int clPoint_x = Grid.GetColumn(rec);
30
-
31
16
  int clPoint_y = Grid.GetRow(rec);
32
-
33
17
  ```
34
-
35
18
  [Grid.GetColumn(UIElement) メソッド (System.Windows.Controls) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.controls.grid.getcolumn?view=netframework-4.7.2#System_Windows_Controls_Grid_GetColumn_System_Windows_UIElement_)
36
-
37
-
38
-
39
19
  [Grid.GetRow(UIElement) メソッド (System.Windows.Controls) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.controls.grid.getrow?view=netframework-4.7.2#System_Windows_Controls_Grid_GetRow_System_Windows_UIElement_)
40
-
41
-
42
-
43
-
44
20
 
45
21
  ---
46
22
 
47
-
48
-
49
23
  前回`ClickCount`をご紹介しましたが、使えませんでしたか?(ダブルクリック判定時間が気に食わないとか?)