About InfoBarMessageControl and WarningAndErrorValidator

Jul 6, 2011 at 5:28 PM

I have inserted both controls inside a regular WPF Window in this way:

<Catel:InfoBarMessageControl Grid.Row="1" Visibility="Visible" Height="20" Text="aaaaaaaaaaa" Background="Blue" Mode="Overlay">

<Catel:WarningAndErrorValidator Source="{Binding Trip}" Visibility ="Visible" />

</Catel:InfoBarMessageControl>

I have a DatePicker bound to the Date property that belongs to the Trip Object.

When I change the picker's SelectedDate the validate members from the Trip object are properly called, but

I don't see any effect on the above controls. Am I missing something?

Thanks in advance for your help.

 

Coordinator
Jul 6, 2011 at 6:40 PM

does the Trip object implement INotifyPropertyChanged and IDataErrorInfo? And is the infobarmessagecontrol located at the outside of the window (thus is it the layoutroot)?

Jul 6, 2011 at 7:24 PM

The Trip Objects Inherits from DataObject. Now I have the following markup for <DatePicker>:

 

 

<DatePicker Grid.Row="1" Grid.Column="0" Name="TripDate" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin ="2,2,2,2" >

 

<DatePicker.SelectedDate>

 

<Binding Path ="Trip.Date">

 

<Binding.ValidationRules>

 

<DataErrorValidationRule />

 

<ExceptionValidationRule />

 

</Binding.ValidationRules>

 

</Binding >

 

</DatePicker.SelectedDate>

</DatePicker>

 The validation seems to work because the control style's changes properly (to the "red" state), but nothing shows up inside the infobarmessagecontrol.

The Infobarmessagecontrol is located inside the grid layout. Is this wrong?

Thanks very much for your quick answer.



 

 

 

 

 

 
Coordinator
Jul 6, 2011 at 7:59 PM
Did you make sure there are no binding errors on the WarningAndErrorValidator? If you set the error in the ValidateFields method using SetFieldError, it shoukd work correctly. Can you write a very small reproducable project?

Sent from my Android phone using TouchDown (www.nitrodesk.com)


-----Original Message-----
From: jsaer [notifications@codeplex.com]
Received: Wednesday, 06 Jul 2011, 20:24
To: Geert van Horrik [geert@catenalogic.com]
Subject: Re: About InfoBarMessageControl and WarningAndErrorValidator [Catel:264126]

From: jsaer

The Trip Objects Inherits from DataObject. Now I have the following markup for <DatePicker>:

<DatePicker Grid.Row="1" Grid.Column="0" Name="TripDate" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin ="2,2,2,2" >

<DatePicker.SelectedDate>

<Binding Path ="Trip.Date">

<Binding.ValidationRules>

<DataErrorValidationRule />

<ExceptionValidationRule />

</Binding.ValidationRules>

</Binding >

</DatePicker.SelectedDate>

</DatePicker>

The validation seems to work because the control style's changes properly (to the "red" state), but nothing shows up inside the infobarmessagecontrol.

The Infobarmessagecontrol is located inside the grid layout. Is this wrong?

Thanks very much for your quick answer.



Jul 6, 2011 at 8:36 PM

This is my class.
The validation members are properly called when expected...
By the way: Did I mention that I'm running under .NET 4?

namespace

 

GDE.ViewModels

{

 

///

<summary>

 

///

TripDescriptor Data object class which fully supports serialization, property changed notifications,

 

///

backwards compatibility and error checking.

 

///

</summary>

#if

 

!SILVERLIGHT

[

Serializable

]

#endif

 

public class TripDescriptor : DataObjectBase<TripDescriptor

>

{

#region

 

Variables

#endregion

 

#region

 

Constructor & destructor

 

///

<summary>

 

///

Initializes a new object from scratch.

 

///

</summary>

 

public

TripDescriptor() { }

#if

 

!SILVERLIGHT

 

///

<summary>

 

/// Initializes a new object based on <see cref="SerializationInfo"/>

.

 

///

</summary>

 

/// <param name="info"><see cref="SerializationInfo"/> that contains the information.

</param>

 

/// <param name="context"><see cref="StreamingContext"/>.

</param>

 

protected TripDescriptor(SerializationInfo info, StreamingContext

context)

:

base

(info, context) { }

#endif

#endregion

 

#region

 

Properties

 

// TODO: Define your custom properties here using the dataprop code snippet

 

///

<summary>

 

///

Gets or sets the property value.

 

///

</summary>

 

public int

Number

{

 

get { return GetValue<int

>(NumberProperty); }

 

set { SetValue(NumberProperty, value

); }

}

 

///

<summary>

 

///

Register the Number property so it is known in the class.

 

///

</summary>

 

public static readonly PropertyData NumberProperty = RegisterProperty("Number", typeof(int

), 0);

#endregion

 

///

<summary>

 

///

Gets or sets the property value.

 

///

</summary>

 

public DateTime

Date

{

 

get { return GetValue<DateTime

>(DateProperty); }

 

set { SetValue(DateProperty, value

); }

}

 

///

<summary>

 

///

Gets or sets the property value.

 

///

</summary>

 

public string

Username

{

 

get { return GetValue<string

>(UsernameProperty); }

 

set { SetValue(UsernameProperty, value

); }

}

 

///

<summary>

 

///

Register the Username property so it is known in the class.

 

///

</summary>

 

public static readonly PropertyData UsernameProperty = RegisterProperty("Username", typeof(string), "USER"

);

 

///

<summary>

 

///

Register the name property so it is known in the class.

 

///

</summary>

 

public static readonly PropertyData DateProperty = RegisterProperty("Date", typeof(DateTime), DateTime

.Now);

 

 

///

<summary>

 

///

Gets or sets the property value.

 

///

</summary>

 

public string

Observations

{

 

get { return GetValue<string>(ObservationsProperty); }

 

set { SetValue(ObservationsProperty, vale

); }

}

 

///

<summary>

 

///

Register the Observations property so it is known in the class.

 

///

</summary>

 

public static readonly PropertyData ObservationsProperty = RegisterProperty("Observations", typeof(string), ""

);

#region

 

Methods

 

///

<summary>

 

///

Validates the fields.

 

///

</summary>

 

protected override void

ValidateFields()

{

 

// TODO: Implement any field validation of this object. Simply set any error by using the SetFieldError method

 

if (Date.Date < DateTime .Now.Date)

SetFieldError(

 
"Date", "La fecha ingresada es inválida"

);

}

 

///

<summary>

 

///

Validates the business rules.

 

///

</summary>

 

protected override void

ValidateBusinessRules()

{

 

// TODO: Implement any business rules of this object. Simply set any error by using the SetBusinessRuleError method

}

#endregion

}

}

 

Coordinator
Jul 7, 2011 at 7:36 AM

Validation should work out of the box. Are you using the official latest version or the latest build? The official 1.4 has an issue with themes and styles, so you should either use the 3.5 version (can be used in 4.0 as well) or use the latest source to build a version yourself (is very stable too).

Jul 8, 2011 at 1:51 PM

As suggested, I have downgraded the Catel's version from 4 to 3.5 (Still working under .NET 4.0) And now it works like a charm without changes.

Thanks again for your support.

Coordinator
Jul 8, 2011 at 1:52 PM

No problem, you are welcome. Glad I could be of any help.

We are working very hard towards 2.0, we will make sure you will not be disappointed :)