Silverlight 3: CustomValidator BUG

Oct 25, 2009 at 6:57 AM

HI,

Nice work,Thanks

 

Use last vision of Validator toolkit in silverlight 3,you will get compile-time error:

   No overload for '*******' matches delegate 'OnValidateControl'

==========================================

 	/**
     	*  CustomValidator.cs
     	* */
	public class CustomValidator : ValidatorBase
	{
        /**
         * In Silverlight 3 , Custom event must be like this:
         */
        public delegate bool OnValidateControl( object ElementToValidate ,/*you need add another para */object arg);

		//public delegate bool OnValidateControl(object ElementToValidate);

		public event OnValidateControl CustomValidate = null;

		protected override bool ValidateControl()
		{
			if (CustomValidate != null)
			{
				//return CustomValidate(base.ElementToValidate);
                return CustomValidate( base.ElementToValidate ,null);
			}
			return true;
		}
	}

        /**
         * 
         * ValidatorDemo.Page.cs
         * 
         * */
	//private bool CustomValidator_CustomValidate(object ElementToValidate)
        private bool CustomValidator_CustomValidate( object ElementToValidate ,object arg)
	{
		TextBox box = ElementToValidate as TextBox;
		return box.Text == "Custom";
	}
==========================================