Пример #1
0
        }                                   //to avoid an XAML annoying warning: "No constructor for type 'xyz' has 0 parameters."  Somehow the inherited one doesn't do the trick!?!  I guess it's a reflection buggy.

// ReSharper restore EmptyConstructor

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || value == DBNull.Value)
            {
                return(Visibility.Visible);
            }
            return(StringEvaluator.EvalToBool(parameter.ToString().Replace("?", value.ToString())) ? Visibility.Visible : Visibility.Collapsed);
        }
Пример #2
0
        }                             //to avoid an XAML annoying warning: "No constructor for type 'xyz' has 0 parameters."  Somehow the inherited one doesn't do the trick!?!  I guess it's a reflection buggy.

// ReSharper restore EmptyConstructor

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var expression = parameter.ToString().Replace("?", (value ?? "").ToString());

            if (VariableReplacement != null)
            {
                VariableReplacement(ref expression);
            }
            return(StringEvaluator.EvalToBool(expression.ToLower())); //nugget:
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="drv"></param>
        /// <param name="isValid"></param>
        /// <param name="fieldName">to reference another field to be invalidated as well, comma delimit with no spaces (yeah i know it's hacky)</param>
        /// <param name="doValidation"> </param>
        /// <param name="expression"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        protected bool ValidateGeneric(DataRowView drv, ref bool isValid, string fieldName, bool doValidation = true, string expression = "'?' != ''", string message = "Required")
        {
            //if (!drv.IsDirty()) return (true);

            string[] flds = fieldName.Split(',');
            if (flds.Length == 2)
            {
                fieldName = flds[0];
            }

            bool isvalid = true;

            if (doValidation)
            {
                isvalid = StringEvaluator.EvalToBool(expression.Replace("?", drv[fieldName].ToString()));
            }
            isValid = isValid && isvalid;

            //if error, set error and notify UI, otherwise clear any existing errors
            if (!isvalid)
            {
                if (flds.Length == 2)
                {
                    drv.SetColumnError(flds[1], message);
                }
                drv.SetColumnError(fieldName, message); //nugget: setting errors on ADO.Net DataRowView fields which propogate all the way back up to little red boxes & tooltips on the corresponding UI widgets
            }
            else
            {
                if (flds.Length == 2)
                {
                    drv.ClearColumnError(flds[1]);
                }
                drv.ClearColumnError(fieldName);
            }

            return(isvalid);
        }
Пример #4
0
        }                             //to avoid an XAML annoying warning: "No constructor for type 'xyz' has 0 parameters."  Somehow the inherited one doesn'SelectedFoldersTable do the trick!?!  I guess it's a reflection bug.

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return(StringEvaluator.EvalToBool(parameter.ToString().Replace("?", value.ToString()).ToLower())); //nugget:
        }