views:

13

answers:

0

Hi there, I tried to get an answer for my problem on silverlight.net however no luck so I thought I would try here out.

I have created a ria entry form inside a child window. I am trying to add a combobox to the form which I am having problems with.

 <ComboBox x:Name="comboType"

                                            DisplayMemberPath="TypeInfo" 
                                  SelectedValuePath="TypeID"
                                       />

I am populating the combo like this

    void formAdd_ContentLoaded(object sender, DataFormContentLoadEventArgs e)
    {
        var combo = (ComboBox)formAdd.FindNameInContent("comboType");
        if (combo != null)
        {
            combo.ItemsSource = ItemTypes;
            combo.SelectedIndex = 0;
        }
    }

    void formAdd_Loaded(object sender, RoutedEventArgs e)
    {
        ItemTypes= GetItemTypes();
    }

    private List<ItemType>GetItemTypes()
    {
        List<ItemType> itemType= new List<ItemType>(); 
        itemType.Add(new ItemType(0, "Please Select")); 
        itemType.Add(new ItemType(1, "Value 1")); 
        itemType.Add(new ItemType(2, "Value 2"));
        return itemTypeType;
    }

When I try to insert the value I get a validation error telling me that my combobox doesnt contain a value. What am I doing wrong?

Any advise would be great!