質問編集履歴

1

コードビハインド側の追加

2021/05/01 01:16

投稿

K.KATSU2
K.KATSU2

スコア10

test CHANGED
File without changes
test CHANGED
@@ -44,19 +44,19 @@
44
44
 
45
45
  <StackPanel>
46
46
 
47
- <DataGrid Name="dataGrid" CanUserAddRows="True"
47
+ <DataGrid Name="dataGrid" CanUserAddRows="True" ItemsSource="{Binding Members}"
48
48
 
49
49
  ScrollViewer.HorizontalScrollBarVisibility="Disabled" Height="291">
50
50
 
51
51
  <DataGrid.Columns>
52
52
 
53
- <DataGridTextColumn Header="名前" Width="*" />
53
+ <DataGridTextColumn Header="名前" Binding="{Binding Name}" Width="*" />
54
54
 
55
- <DataGridTextColumn Header="部門" Width="80" />
55
+ <DataGridTextColumn Header="部門" Binding="{Binding Department}" Width="80" />
56
56
 
57
- <DataGridTextColumn Header="権限" Width="80" />
57
+ <DataGridTextColumn Header="権限" Binding="{Binding Authority}" Width="80" />
58
58
 
59
- <DataGridTextColumn Header="メールアドレス" Width="150" />
59
+ <DataGridTextColumn Header="メールアドレス" Binding="{Binding Mail}" Width="150" />
60
60
 
61
61
  </DataGrid.Columns>
62
62
 
@@ -86,6 +86,60 @@
86
86
 
87
87
 
88
88
 
89
+ [コードビハインド]
90
+
91
+ ```C#
92
+
93
+ public class MemberRegistrationViewModel : BindableBase
94
+
95
+ {
96
+
97
+ public MemberRegistrationViewModel()
98
+
99
+ {
100
+
101
+
102
+
103
+ }
104
+
105
+
106
+
107
+ private ObservableCollection<Member> _members = new ObservableCollection<Member>();
108
+
109
+ public ObservableCollection<Member> Members
110
+
111
+ {
112
+
113
+ get { return _members; }
114
+
115
+ set { SetProperty(ref _members, value); }
116
+
117
+ }
118
+
119
+ }
120
+
121
+
122
+
123
+ public class Member
124
+
125
+ {
126
+
127
+ public string Name { get; set; }
128
+
129
+ public string Department { get; set; }
130
+
131
+ public string Authority { get; set; }
132
+
133
+ public string Mail { get; set; }
134
+
135
+
136
+
137
+ }
138
+
139
+ ```
140
+
141
+
142
+
89
143
  ### 試したこと
90
144
 
91
145