Exemple #1
0
        static void ApplyAttributes(PropertyDescriptor descriptor, Binding binding, DataGridColumn column)
        {
            if (descriptor.PropertyType.IsEnum)
            {
                binding.Converter = new UnderlyingEnumValueConverter();
                column.SetTemplate((ControlTemplate)MetadataTableViews.Instance[descriptor.PropertyType.Name + "Filter"]);
            }
            var stringFormat = descriptor.Attributes.OfType <StringFormatAttribute>().FirstOrDefault();

            if (stringFormat != null)
            {
                binding.StringFormat = stringFormat.Format;
                if (!descriptor.PropertyType.IsEnum && stringFormat.Format.StartsWith("X", StringComparison.OrdinalIgnoreCase))
                {
                    column.SetTemplate((ControlTemplate)MetadataTableViews.Instance["HexFilter"]);
                }
            }
        }