idataerrorinfo

DataGridCell Validation.ErrorTemplate ignored

假如想象 提交于 2019-12-30 18:33:41
问题 I'm trying to set the Validation.ErrorTemplate of the DataGridCells, here's the xaml code: <Style x:Key="{x:Type DataGridCell}" x:Uid="dataGridCellErrorTemplate" TargetType="{x:Type DataGridCell}"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate > <Border BorderBrush="Green" BorderThickness="2" ToolTip="Heidenei"></Border> </ControlTemplate> </Setter.Value> </Setter> <!-- following line only for demonstration that the setter is working ... --> <Setter Property=

Validation.HasError does not trigger again if new error comes in while already true

六眼飞鱼酱① 提交于 2019-12-24 03:08:21
问题 I use MVVM and my object implement IDataErrorInfo. When a property is set, I run custom validation methods and if the validation passes, I return String.empty, which sets Validation.HasError to false. If the validation fails, Validation.HasError is set to true. I have a style that I use for "required controls" (controls that will perform the validation) and set's the ToolTip of the control to whatever the error is like this: <Style x:Key="RequiredControl" TargetType="{x:Type Control}" >

Validation.HasError does not trigger again if new error comes in while already true

早过忘川 提交于 2019-12-24 03:08:13
问题 I use MVVM and my object implement IDataErrorInfo. When a property is set, I run custom validation methods and if the validation passes, I return String.empty, which sets Validation.HasError to false. If the validation fails, Validation.HasError is set to true. I have a style that I use for "required controls" (controls that will perform the validation) and set's the ToolTip of the control to whatever the error is like this: <Style x:Key="RequiredControl" TargetType="{x:Type Control}" >

Tooltip Not Showing Up When No Validation Error WPF

Deadly 提交于 2019-12-22 06:51:22
问题 I searched and did not see a solution. I can only get the validation to show the tooltip if I do not set a tooltip in the combo box tooltip property. I would like to see the validation error tooltip when one is present otherwise show the tooltip from the combobox property. The validation tooltip shows up fine when I remove the text from the tooltip property (i.e. from the property panel for the combo box). The XAML in Application.Resources (App.XAML)for the tooltip to show the validation

Force IDataErrorInfo validation

耗尽温柔 提交于 2019-12-21 07:07:39
问题 I have two controls on some panel: textbox and combobox: <TextBox Text="{Binding ShapeName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" /> <ComboBox SelectedItem="{Binding ActiveStageViewModel, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" /> I need to force idataerrorinfo validation for textbox, when I select something on combobox. How to do that? The code from viewmodel: string IDataErrorInfo.this[string

Using IDataErrorInfo with Nested Objects

余生颓废 提交于 2019-12-21 05:12:19
问题 I am using MVVM and I want to use IDataErrorInfo to validate my View. My current implementation includes Nested objects and different ViewModels. e.g. Business Entity 'Customer' contains Business Entity 'Address'. I am accessing Address directly in my view, like "Customer.Address". To validate changes in Address I would have to implement IDataErrorInfo in Address. I use Customer or Address in different Views/ViewModels. Usage in different Views/ViewModels lead to different Validation Behavior

using IDataErrorInfo in asp.net mvc

為{幸葍}努か 提交于 2019-12-18 03:49:23
问题 I've got a simple address entry app that I'm trying to use the IDataErrorInfo interface as explained on the asp.net site. It works great for items that can be validated independently, but not so well when some items depend on others. For example, validating the postal code depends on the country: private string _PostalCode; public string PostalCode { get { return _PostalCode; } set { switch (_Country) { case Countries.USA: if (!Regex.IsMatch(value, @"^[0-9]{5}$")) _errors.Add("PostalCode",

WPF DataGrid validation errors not clearing

眉间皱痕 提交于 2019-12-17 10:46:07
问题 So I have a WPF DataGrid , which is bound to an ObservableCollection . The collection has validation on its members, through IDataErrorInfo . If I edit a cell in a way so as to be invalid, and then tab away from it before hitting enter, then come back and make it valid, the cell will stop showing invalid, however, the "!" at the head of the row will still be there, and the ToolTip will reference the previous, invalid value. 回答1: Not using Mode=TwoWay for DataGridTextColumns solves one version

Problem with validation and multibinding

南笙酒味 提交于 2019-12-12 14:29:03
问题 In my WPF application I use the following xaml: ... <TextBox services:TextBoxService.IsFocused="{Binding Path=IsSelected, Mode=OneWay}" FocusVisualStyle="{x:Null}"> <MultiBinding Converter="{StaticResource mconv_operableToString}" UpdateSourceTrigger="PropertyChanged"> <Binding Path="Value" Mode="TwoWay" NotifyOnValidationError="True" /> <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" Path="DataContext.Status" Mode="OneWay" /> </MultiBinding> The

WPF IDataErrorInfo multiple field validation

时光怂恿深爱的人放手 提交于 2019-12-12 05:14:00
问题 What is a good way to integrate multiple field validation with IDataErrorInfo? Let say that I have a dialog with 3 textboxes for ftp information URL Username Password I have put the Required attribute on the fields (assume a normal TextBox for the password). I validate the ftp connection when the user press "OK". At the moment I show a dialog but it would be nice if I could trigger the Validation error style on ftp connection errors. I have looked at Validation.MarkInvalid but don't