ComponentOne Basic Library for UWP
Basic Library Overview / DropDown for UWP / DropDown for UWP Task-Based Help / Adding Content to C1DropDown
In This Topic
    Adding Content to C1DropDown
    In This Topic

    You can add any sort of arbitrary content to a C1DropDown control. This includes text, images, and other standard and 3rd-party controls. In this example, you'll add a Button control to a C1DropDown control, but you can customize the steps to add other types of content instead.

    In XAML

    For example, to add a Button control to the drop-down add <Button Height="30" Name="button1" Width="100">Hello World!</Button> within the <Xaml:C1DropDown> tag so that it appears similar to the following:

    Markup
    Copy Code
    <Xaml:C1DropDown HorizontalAlignment="Center" VerticalAlignment="Top" Width="100">
      <Xaml:C1DropDown.Content>
        <Button Height="30" Name="button1" Width="100">Hello World!</Button>
      </Xaml:C1DropDown.Content>
    </Xaml:C1DropDown>
    
       

    In Code

    For example, to add a Button control to the drop-down box, add code to the page's constructor so it appears like the following:

    C#
    Copy Code
    public MainPage()
            {
                this.InitializeComponent();
                C1DropDown c1dropdown1 = new C1DropDown();
                c1dropdown1.Height = 30;
                c1dropdown1.Width = 100;
                LayoutRoot.Children.Add(c1dropdown1);
    
                Button c1button1 = new Button();
                c1button1.Content = "Hello World!";
                c1dropdown1.Content = c1button1;
            }
    

     

     What You've Accomplished

    You've added a button control to the C1DropDown control. Run the application and click the drop-down arrow. Observe that the Button control has been added to the drop-down box. Note that to add multiple items to the C1DropDown control, add a Grid or other panel to the C1DropDown control, and add items to that panel.

    See Also