Windows 8 and NotifyOnValidationError

Windows 8 and NotifyOnValidationError

Old forum URL: forums.lhotka.net/forums/t/11569.aspx


TSF posted on Monday, September 10, 2012

What is the best way to go about displaying a validation error to the user for a particular field on a Windows 8 (WinRT) app?

RockfordLhotka replied on Monday, September 10, 2012

One solution is to use the Csla.Xaml.PropertyInfo control as a data source to get at the metastate and other data about a property. Then you can bind other UI elements to that PropertyInfo control, like a tooltip, or red Rectangle or whatever you'd like.

TSF replied on Tuesday, September 11, 2012

Thanks, Rocky.  Would you happen to have an example of using that in a style applicable to WinRT?  I see the examples of it being used in styles in the Using series projects, but I know Triggers aren't supported in WinRT.

TSF replied on Tuesday, September 11, 2012

I have the following XAML defined for the PropertyInfo control:

<csla:PropertyInfo x:Name="piField1" Source="{Binding Model}" Property="{Binding Model.Field1}"/>

I then have the following Border element with its BorderThickness bound to the PropertyInfo's IsValid path, as follows:

<Border BorderBrush="Red" BorderThickness="{Binding ElementName=piField1, Path=IsValid, Converter={StaticResource ValidationToBorderConverter}}" Margin="0,5,0,0" >
...
</Border>

However, the BorderThicnkness binding is only triggered once when the page is first loaded.  If I update the Field1 property of the BO, the BorderThickness binding never gets triggered.  What am I doing wrong?  (Note - "Model" is my ViewModelBase class that is set as the page's data context.)

Copyright (c) Marimer LLC