回答編集履歴
1
見直しキャンペーン中
answer
CHANGED
@@ -1,25 +1,23 @@
|
|
1
|
-
`GetValue`の使い方が間違っています。
|
2
|
-
|
3
|
-
これですと`this.GetValue(Grid.ColumnProperty)`という意味になり、`MainWindow`の`Grid.Column`を取得します。
|
4
|
-
`MainWindow`には`Grid.Column`を付けることはないでしょうから、常に`0`(規定値)が返ってきます。
|
5
|
-
|
6
|
-
`Rectangle`の`GetValue`を呼ぶ必要があります(if内も同じ)
|
7
|
-
```
|
8
|
-
clPoint_x = rec.GetValue(Grid.ColumnProperty);
|
9
|
-
clPoint_y = rec.GetValue(Grid.RowProperty);
|
10
|
-
```
|
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_)
|
12
|
-
|
13
|
-
あるいは`Grid.GetColumn`・`Grid.GetRow`で取得すると、`int`で返ってくるので楽です。
|
14
|
-
```
|
15
|
-
int clPoint_x = Grid.GetColumn(rec);
|
16
|
-
int clPoint_y = Grid.GetRow(rec);
|
17
|
-
```
|
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_)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
---
|
24
|
-
|
1
|
+
`GetValue`の使い方が間違っています。
|
2
|
+
|
3
|
+
これですと`this.GetValue(Grid.ColumnProperty)`という意味になり、`MainWindow`の`Grid.Column`を取得します。
|
4
|
+
`MainWindow`には`Grid.Column`を付けることはないでしょうから、常に`0`(規定値)が返ってきます。
|
5
|
+
|
6
|
+
`Rectangle`の`GetValue`を呼ぶ必要があります(if内も同じ)
|
7
|
+
```cs
|
8
|
+
clPoint_x = rec.GetValue(Grid.ColumnProperty);
|
9
|
+
clPoint_y = rec.GetValue(Grid.RowProperty);
|
10
|
+
```
|
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_)
|
12
|
+
|
13
|
+
あるいは`Grid.GetColumn`・`Grid.GetRow`で取得すると、`int`で返ってくるので楽です。
|
14
|
+
```cs
|
15
|
+
int clPoint_x = Grid.GetColumn(rec);
|
16
|
+
int clPoint_y = Grid.GetRow(rec);
|
17
|
+
```
|
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_)
|
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_)
|
20
|
+
|
21
|
+
---
|
22
|
+
|
25
23
|
前回`ClickCount`をご紹介しましたが、使えませんでしたか?(ダブルクリック判定時間が気に食わないとか?)
|