From 8624ae1ead48d7ddc206486db0c4fc024afac703 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Sat, 12 Sep 2015 18:38:45 +0200 Subject: [PATCH] Allow one way binding with MemberLess value passed as string with ValueChanched event --- src/CompilerServices/CompilerServices.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 1aaeac99..f383c8ee 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -322,13 +322,19 @@ namespace go PropertyInfo piTarget = dstType.GetProperty(binding.MemberName); Type srcValueType = null; + + if (miSrc == null) + //this allow memberless binding with only a name passed as MemberName + //but the value passed has to be a string + srcValueType = typeof(string); + else{ if (miSrc.MemberType == MemberTypes.Property) srcValueType = (miSrc as PropertyInfo).PropertyType; else if (miSrc.MemberType == MemberTypes.Field) srcValueType = (miSrc as FieldInfo).FieldType; else throw new Exception("unandled source member type for binding"); - + } if (!srcValueType.IsValueType) il.Emit(OpCodes.Castclass, srcValueType); else if (piTarget.PropertyType != srcValueType) -- 2.47.3