开发者

How to catch and display warnings to the user

Essentially the warning in our case is just a validation, we don't want to mark it as an error just a warning so the user knows. I was hoping to use the same or similar method used for validation. Currently I'm leaning towards implementing IDataErrorInfo. But I'd like to change the style on display and allow s开发者_运维技巧aving. Has anyone done anything similar? I don't want 2 separate solutions for validation.


during validation, set some corresponding properties. eg: IsInWarning and IsInError.

set these properties according to the validation logic in the error handler and then use a datatemplate to style the items with triggers.

something like that?

(sorry no time to mock up an example now...)


WPF has a built-in mechanism for handling validation via IDataErrorInfo.

There is a good CodeProject article describing the process, but it basically comes down to supplying an ErrorTemplate that's used for items in an error state, and telling WPF to validate your objects. If they implement IDataError info, you can have their style change, plus use that to present error messages directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜