Xceed Toolkit Plus for WPF v5.1 Documentation
Xceed.Wpf.Toolkit Assembly / Xceed.Wpf.Toolkit.PropertyGrid.Attributes Namespace / ItemsSourceAttribute Class
Example


In This Topic
    ItemsSourceAttribute Class
    In This Topic
    Represents an attribute that is set on a property to identify the IItemsSource-derived class that will be used.
    Syntax
    'Declaration
     
    
    <AttributeUsageAttribute(AttributeTargets.All, 
       Inherited=True, 
       AllowMultiple=False)>
    Public Class ItemsSourceAttribute 
       Inherits System.Attribute
    'Usage
     
    
    Dim instance As ItemsSourceAttribute
    [AttributeUsage(AttributeTargets.All, 
       Inherited=true, 
       AllowMultiple=false)]
    public class ItemsSourceAttribute : System.Attribute 
    Remarks
    Use this attribute on a property when a scenario calls for use of a collection of values represented by a ComboBox for a given property.
    Example
    First, create a class that implements IItemsSource.Then decorate the property with the ItemsSource attribute.
    public class FontSizeItemsSource : IItemsSource
    {
        public ItemCollection GetValues()
        {
            ItemCollection sizes = new ItemCollection();
            sizes.Add(5.0, "Five");
            sizes.Add(5.5);
            sizes.Add(6.0, "Six");
            sizes.Add(6.5);
            sizes.Add(7.0, "Seven");
            sizes.Add(7.5);
            sizes.Add(8.0, "Eight");
            sizes.Add(8.5);
            sizes.Add(9.0, "Nine");
            sizes.Add(9.5);
            sizes.Add(10.0);
            sizes.Add(12.0, "Twelve");
            sizes.Add(14.0);
            sizes.Add(16.0);
            sizes.Add(18.0);
            sizes.Add(20.0);
            return sizes;
        }
    }
    public class Person
    {
        [Category("Writing")]
        [DisplayName("Writing Font Size")]
        [Description("This property uses the DoubleUpDown as the default editor.")]
        [ItemsSource(typeof(FontSizeItemsSource))]
        public double WritingFontSize { get; set; }
    }
    Inheritance Hierarchy

    System.Object
       System.Attribute
          Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemsSourceAttribute

    Public Constructors
     NameDescription
    Public ConstructorInitializes a new instance of the ItemsSourceAttribute class using the specified Type.  
    Top
    Public Properties
     NameDescription
    Public PropertyGets or sets the type to use.  
    Public Property (Inherited from System.Attribute)
    Top
    Public Methods
     NameDescription
    Public Method (Inherited from System.Attribute)
    Public Method (Inherited from System.Attribute)
    Public Method (Inherited from System.Attribute)
    Public Method (Inherited from System.Attribute)
    Top
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also