예제 #1
0
        private static DependencyProperty ConvertDependencyProperty(XamlTypeConverter converter, ITypeDescriptorContext context, CultureInfo culture, object ovalue)
        {
            string value = (string)ovalue;

            Type target_type;

            int idx = value.IndexOf('.');

            if (idx > 0)
            {
                target_type = converter.parser.ResolveType(value.Substring(0, idx));
                value       = value.Substring(idx + 1, value.Length - idx - 1);
            }
            else
            {
                target_type = GetTargetType(converter);
            }

            Types.Ensure(target_type);

            ManagedType mt = Deployment.Current.Types.Find(target_type);

            DependencyProperty dp = XamlParser.LookupDependencyProperty((Kind)mt.native_handle, value);

            return(dp);
        }
예제 #2
0
        public DependencyProperty LookupDependencyProperty(Kind kind, string name)
        {
            int dot = name.IndexOf('.');

            if (dot > 0)
            {
                // Its an attached property
                string type = name.Substring(0, dot);
                name = name.Substring(dot + 1, name.Length - dot - 1);

                Type t = Parser.ResolveType(type);

                if (t == null)
                {
                    throw Parser.ParseException("Can not find type '{0}'", type);
                }

                Types.Ensure(t);

                kind = Deployment.Current.Types.TypeToNativeKind(t);
                if (kind == Kind.INVALID)
                {
                    Console.Error.WriteLine("Could not create kind for managed type: {0}", t);
                    return(null);
                }
            }

            try {
                return(XamlParser.LookupDependencyProperty(kind, name));
            } catch (Exception e) {
                Console.Error.WriteLine("Exception while looking up dependency property.");
                Console.Error.WriteLine(e);
                return(null);
            }
        }