I think that will be interesting to share this code before I drop.

If you are looking for an easy way to hang nhibernate validator to
work with wpf:

    public class Album : IDataErrorInfo
    {
         //properties.

        string IDataErrorInfo.this[string columnName]
        {
            get
            {
                string[] messages =
_validatorEngine.GetValidator<Album>()
                    .GetPotentialInvalidValues(columnName, this)
                    .Select(iv => iv.Message)
                    .ToArray();

                return string.Join(Environment.NewLine, messages);
            }
        }


        string IDataErrorInfo.Error
        {
            get
            {
                string[] messages =
_validatorEngine.GetValidator<Album>()
                    .GetInvalidValues(this)
                    .Select(iv => iv.Message)
                    .ToArray();

                return string.Join(Environment.NewLine, messages);
            }
        }
    }

_validatorEngine come from anywhere. ServiceLocator....... I don't
know.


Then in your xaml the only thing that you need is this:

<TextBox Text="{Binding Path=Album.Title,
ValidatesOnDataErrors=true}" />

(the important part is the ValidatesOnDataErrors = true).


I will use the dynamicproxy way in the chinookmediamanager sample.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to