set custom error template for DateTimeEditBox

Editors for WPF Forum

Posted 9 years ago by duyhai
I try to set the custom template for DateTimeEditBox; however, it do not work. Of course, with standard control of Microsoft (textbox, combobox), it work ok.

My code :
<Style TargetType="{x:Type editors:DateTimeEditBox}">
<Setter Property="Margin" Value="3 3 15 3"/>
<Setter Property="IsEnabled" Value="{Binding Path=CanEdit}"/>
<Setter Property="Validation.ErrorTemplate">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Right"
<Border BorderBrush="Red" BorderThickness="1">
<AdornedElementPlaceholder />

So, how do we set a custom validation for datetimeeditbox?

Thanks for your helps.

[Modified at 07/27/2010 02:31 AM]

Comments (2)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA

You set the ErrorTemplate in the same manner as the native WPF controls. What you have above should properly assign the ErrorTemplate.

Keep in mind that it will only show with the binding on DateTimeEditBox.Value is "invalid" or has errors. If you are simply binding it to a DateTime or DateTime? property (that doesn't have any additional business logic behind it), then the ErrorTemplate will never show. The DateTimeEditBox.Value will always be a valid DateTime?.

If you have additional business logic in your property, then you need to ensure that Binding.ValidatesOnExceptions (if using exception) or Binding.ValidatesOnDataErrors (if using IDataErrorInfo) is set to true on the binding assigned to DateTimeEditBox.Value.

If this doesn't help, please put together a small sample project and email it over to our support address. Be sure to remove any executable files from the archive or rename the extension, so it won't be rejected by our email servers.

Actipro Software Support

Posted 9 years ago by duyhai
In fact, I can validation with bind on datetime? (I only need mark mandatory on this property).
So, this problem happen because I use multidatabinding.
Fix: set validation error on binding appropriately
The latest build of this product (v2018.1 build 0675) was released 12 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.