idataerrorinfo

ErrorProvider - Change BackColor Instead of Showing Icon

和自甴很熟 提交于 2019-12-11 12:47:00
问题 I'm stuck with some legacy code that I want to upgrade a bit. I want to change the way the ErrorProvider shows the error status on a Control. Default behavior is the Icon, and a ToolTip if you hover on the icon. I would like to change this behavior to be more similar to what we use in our WPF controls. Which is a red back-color(Salmon pink) and the tool-tip on the control itself. Any tips, links or some way forward EDIT. See my answer below, on what i ended up with. 回答1: ErrorProvider

IDataErrorInfo With Multiple Error Messages for a Property

為{幸葍}努か 提交于 2019-12-11 07:35:19
问题 It appears someone else is having this issue: Validation.HasError does not trigger again if new error comes in while already true The Validation.Error is not updating with the latest error message. It shows the previous error not the one that actually got called last. When I log each return, the PropertyX is greater than or PropertyX is less than is returned, but it does not display that message in my tooltip. It will displays "Required". I also found that my converter for the tooltip does

Force one or more checkboxes to be selected

醉酒当歌 提交于 2019-12-11 03:48:05
问题 I have three checkboxes that have their own error checking as to whether them being checked is valid but I would also like to enforce that at least one must be checked before continuing. I'm currently using IDataErrorInfo for the individual error checking and have tried using BindingGroups to check that at least one is checked with no success. Here's the XAML, <StackPanel Orientation="Horizontal" Margin="5,2"> <Label Content="Checkboxes:" Width="100" HorizontalContentAlignment="Right"/>

Why IDataErrorInfo is showing errors at app startup

空扰寡人 提交于 2019-12-11 03:39:54
问题 I'm implementing IDataErrorInfo in my ViewModel. I have two properties 'Nom' & 'Prenom', which I want to make mandatory #region IDataErrorInfo string IDataErrorInfo.Error { get { return null; } } string IDataErrorInfo.this[string propertyName] { get { return GetValidationError(propertyName); } } #endregion IDataErrorInfo #region Validation private static readonly string[] ValidatedProperties = { "Nom", "Prenom" }; public bool IsValid { get { foreach (string property in ValidatedProperties) if

Enabling or disabling validation upon context

早过忘川 提交于 2019-12-11 02:38:24
问题 Introduction I have two TextBox in my view, each binded to some properties in my view-model ( Property1 , Property2 ). TextBox are alternatively enabled upon some boolean, and properties, are validated using IDataErrorInfo in the view-model + some styling in the view. Problem I would like to disable validation style when items are disabled. NB1: Currently, solution I found is to change validation scheme directly in the view-model, but this requires to notify for property changes in order to

How can I stop IDataErrorInfo from firing for new items?

丶灬走出姿态 提交于 2019-12-10 11:42:04
问题 I am developing a WPF application (using MVVM) and have implemented IDataErrorInfo on my ViewModel. Part of my validation checks that mandatory fields have been entered. This works perfectly for editing existing records but doesn't provide a nice user experience when adding new records. As soon as I load the new view, the mandatory fields are highlighted as invalid. Is there a (preferably non-hacky) solution to this? It seems a pretty standard thing to want, so I'm hoping I'm missing

Is IDataErrorInfo ignored during model validation in MVC 2?

时光毁灭记忆、已成空白 提交于 2019-12-10 10:44:10
问题 I currently migrated my project to MVC 2 and IDataErrorInfo doesn't seem to work when using default model binding and validation. Is it cut out? 回答1: SUMMARY I posted this error to MVC 2 issue tracker: http://aspnet.codeplex.com/WorkItem/View.aspx?WorkItemId=4891 It will be resolved in next preview release. DefaultModelBinder in MVC 1.0: protected virtual void OnPropertyValidated(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor,

How can I stop IDataErrorInfo from firing for new items?

我的未来我决定 提交于 2019-12-08 08:01:27
I am developing a WPF application (using MVVM) and have implemented IDataErrorInfo on my ViewModel. Part of my validation checks that mandatory fields have been entered. This works perfectly for editing existing records but doesn't provide a nice user experience when adding new records. As soon as I load the new view, the mandatory fields are highlighted as invalid. Is there a (preferably non-hacky) solution to this? It seems a pretty standard thing to want, so I'm hoping I'm missing something simple. Use a flag that indicates whether the record is new. Check this flag in your implementation

WPF- Validation -The validation error message goes behind the other controls because of AdornerDecorator

烈酒焚心 提交于 2019-12-07 06:31:51
问题 I have implemented IDataErrorInfo in my ViewModel to return a string if the text box has error. public string this[string columnName] { get { return "Error-- This is a long error message - sd"; } } But this error message goes behind the other control on the UI as shown below. Below is the xaml: <Window x:Class="Test.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="600" Width="600"> <Window

Implementing IDataErrorInfo in a view model

给你一囗甜甜゛ 提交于 2019-12-07 05:30:11
问题 I have a ViewModel class with a Phone object as one of its properties , my main window data context is set to the ViewModel, do I need to implement IDataErrorInfo on the underlying Phone model class or the ViewModel class that contains the Phone property? Also what would be the correct way to bind the textbox I'm trying to validate to my ViewModel.NewPhone.StringProperty? Many thanks 回答1: The decision of where to implement IDataErrorInfo really depends on your application's logic. For example