No error messages w/IDataErrorInfo Datavalidation

Grids for WPF Forum

Posted 13 years ago by Pat Maneely - Software Engineering Manager, Cobham Aerospace
Avatar
I'm trying to use IDataErrorValidation to indicate errors on my property grid.

When an validation error occurs, the border of the associated box on the grid is turned red, but the error message doens't appear.

Can you please show me the error of my ways.

Here's the XAML. The PropGrid is in a Wizard Page...

<wizard:WizardPage x:Name="msmFSPPage"
Caption="System Configuration Parameters"
Description="This page contains the Parameters necessry to configuration the System"
Title="System Configuration Parameters Page"
HelpButtonVisible="False">
<propgrid:PropertyGrid IsSummaryVisible="True" SelectedObject="{Binding Path=SystemData}">
<propgrid:PropertyGrid.DataFactory>
<propgrid:TypeDescriptorFactory />
</propgrid:PropertyGrid.DataFactory>
</propgrid:PropertyGrid>
</wizard:WizardPage>
...

There is a View Model in between that has a property to bind the XAML to the following class.

Here's the code that has the data validation

class SystemData : INotifyPropertyChanged, IDataErrorInfo
{
...
/// <summary>
/// Part Number
/// </summary>
public string PartNum
{
get { return partno_; }
set { partno_ = value; NotifyPropertyChanged("PartNum"); }
}

[Browsable(false)]
public string this[string propertyName]
{
get
{
switch (propertyName)
{
case "PartNum":
lastError_ = ValidatePartNum(partno_, 0);
break;

default:
lastError_ = null;
break;
}
return lastError_;
}
}


protected string ValidatePartNum(string partNumber, int index)
{
if (...)
return "Invalid Part Number";
return null;
}
...
}

Comments (2)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Pat,

That's the default behavior of the Validation.ErrorTemplate. If you want to show the error message somewhere, then you'd have to set that up manually. You could use the ToolTip of the underlying control in the property editor, but you'd have to define an implicit Style per control (i.e TextBox, ComboBox). Something like the one shown here:
http://stackoverflow.com/questions/1237997/wpf-show-textbox-tooltip


Actipro Software Support

Posted 13 years ago by Pat Maneely - Software Engineering Manager, Cobham Aerospace
Avatar
Thanks - I guess I should have tried that first. I got the impression from you docs it was already built into the styles.
The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.