Пример #1
0
            SelectTemplate(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null && item is PropertyModel)
            {
                Property prop = (Property)((PropertyModel)item).Value;
                object[] attributes = prop.GetType().GetCustomAttributes(typeof(PropertyDefinitionAttribute), false);

                if (attributes.Length > 0)
                {
                    PropertyDefinitionAttribute attribute = (PropertyDefinitionAttribute)attributes[0];
                    return (element.FindResource(attribute.ViewName) as DataTemplate);
                }
            }

            return null;
        }
Пример #2
0
        public PropertyModel(uint id, Property property, bool isArray, int arrayIndex)
        {
            Id          = id;
            Value       = property;
            _isArray    = isArray;
            _arrayIndex = arrayIndex;

            //check if a record exists for this property. If not, create it.
            if (TGIRegistry.Instance.Properties.Cache.TryGetValue(Id, out _propertyDetails) == false)
            {
                _propertyDetails = new TGIRecord()
                {
                    Id = id
                };
            }

            object[] attributes = property.GetType().GetCustomAttributes(typeof(PropertyDefinitionAttribute), false);

            if (attributes.Length > 0)
            {
                PropertyDefinitionAttribute attribute = (PropertyDefinitionAttribute)attributes[0];
                _propertyType = attribute.Name;
            }
        }