質問編集履歴

1

add

2018/03/23 00:34

投稿

meshkit
meshkit

スコア72

test CHANGED
File without changes
test CHANGED
@@ -204,6 +204,54 @@
204
204
 
205
205
 
206
206
 
207
+ 追記
208
+
209
+ ```C#
210
+
211
+ ValidationContext vc = new ValidationContext(textbox);
212
+
213
+ var validationResults = new Collection<ValidationResult>();
214
+
215
+ bool result = false;
216
+
217
+ result = TryValidateObject(textbox, vc, validationResults, result);
218
+
219
+ if (!result)
220
+
221
+ MessageBox.Show("Empty");
222
+
223
+
224
+
225
+ public static bool TryValidateObject(
226
+
227
+ object instance,
228
+
229
+ ValidationContext validationContext,
230
+
231
+ ICollection<ValidationResult> validationResults,
232
+
233
+ bool validateAllProperties
234
+
235
+ )
236
+
237
+ {
238
+
239
+ TextBox textbox = instance as TextBox;
240
+
241
+ if (string.IsNullOrEmpty(textbox.Text)) return false;
242
+
243
+ else return true;
244
+
245
+ }
246
+
247
+
248
+
249
+ ```
250
+
251
+
252
+
253
+
254
+
207
255
  ### 補足情報(FW/ツールのバージョンなど)
208
256
 
209
257
  Visual Studio 2015 Pro