質問編集履歴
2
質問の方法を変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ViewModelの中に
|
1
|
+
ViewModelの中身を動的に変更する
|
test
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
public MainWindow()
|
7
7
|
{
|
8
8
|
InitializeComponent();
|
9
|
-
|
9
|
+
|
10
|
+
|
10
11
|
}
|
11
12
|
}
|
12
13
|
|
@@ -26,9 +27,24 @@
|
|
26
27
|
this.Models.Add(new Model() { Label = "Tokyo", Latitude = "35.5090627", Longitude = "139.2093882" });
|
27
28
|
}
|
28
29
|
|
29
|
-
public void AddExecute(string Label, string Latitude, string Longitude) =>
|
30
|
-
this.Models.Add(new Model() { Label = Label, Latitude = Latitude, Longitude = Longitude });
|
31
|
-
|
32
30
|
}
|
33
31
|
```
|
32
|
+
```xaml
|
33
|
+
<Grid.DataContext>
|
34
|
+
<local:ViewModel />
|
35
|
+
</Grid.DataContext>
|
36
|
+
<syncfusion:SfMap x:Name="Maps">
|
37
|
+
<syncfusion:SfMap.Layers>
|
38
|
+
<syncfusion:ShapeFileLayer Uri="./Japan.shp"
|
39
|
+
Markers="{Binding Models}">
|
40
|
+
</syncfusion:ShapeFileLayer>
|
41
|
+
</syncfusion:SfMap.Layers>
|
42
|
+
</syncfusion:SfMap>
|
43
|
+
```
|
44
|
+
Grid.DataContextの中にあるViewModelをコード側から動的に変更したいです。
|
45
|
+
しかし、
|
46
|
+
```C#
|
47
|
+
var Point = new ViewModel();
|
34
|
-
|
48
|
+
Point.Models.Add(new Model() { Label = "Tokyo", Latitude = "35.5090627", Longitude = "139.2093882" });
|
49
|
+
```
|
50
|
+
このようにインスタンスを作って追加しても変更できませんでした。どのようにすれば変更できるでしょうか。
|
1
privateをpublicに変更 AddExecuteを入れたい部分を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
public MainWindow()
|
7
7
|
{
|
8
8
|
InitializeComponent();
|
9
|
+
AddExecute("Tokyo","35.5090627","139.2093882");//ここで実行させたい
|
9
10
|
}
|
10
11
|
}
|
11
12
|
|
@@ -25,7 +26,7 @@
|
|
25
26
|
this.Models.Add(new Model() { Label = "Tokyo", Latitude = "35.5090627", Longitude = "139.2093882" });
|
26
27
|
}
|
27
28
|
|
28
|
-
p
|
29
|
+
public void AddExecute(string Label, string Latitude, string Longitude) =>
|
29
30
|
this.Models.Add(new Model() { Label = Label, Latitude = Latitude, Longitude = Longitude });
|
30
31
|
|
31
32
|
}
|