0

a simple xaml:

<ComboBox
    Height="23" Name="status"
    IsReadOnly="False"
    ItemsSource="?"
    Width="120">
</ComboBox>

What you need to write to С# that stick items in the drop-down list right here

user1478466
  • 29
  • 2
  • 7

1 Answers1

3

Your ItemsSource is a simple binding to a collection of [something] that will fill out the combolist, here's a quick sample:

public class MyDataSource
{
    public IEnumerable<string> ComboItems 
    {
        get
        {
            return new string[] { "Test 1", "Test 2" };
        }
    }
}

<ComboBox
    Height="23" Name="status"
    IsReadOnly="False"
    ItemsSource="{Binding Path=ComboItems}"
    Width="120">
</ComboBox>

That's not a complete sample, but it gives you the idea.

It's also worth noting that you don't have to use the ItemsSource property, this is also acceptable:

<ComboBox
    Height="23" Name="status"
    IsReadOnly="False"
    Width="120">
    <ComboBox.Items>
        <ComboBoxItem>Test 1</ComboBoxItem>
        <ComboBoxItem>Test 2</ComboBoxItem>
    </ComboBox.Items>
</ComboBox>
André Santaló
  • 639
  • 1
  • 9
  • 24
CodingGorilla
  • 19,612
  • 4
  • 45
  • 65