XAML
<df:DataForm x:Name="MobCrud"
AutoEdit="True"
AutoCommit="True"
AutoGenerateFields="False"
VerticalAlignment="Top"
CommandButtonsVisibility="All"
Header="Mob Details"
CanUserAddItems="True"
CanUserDeleteItems="True"
CurrentItem="{StaticResource newMob}"
>
<df:DataForm.Fields>
<df:DataFormTextField Binding="{Binding Name}" FieldLabelContent="Name" />
<df:DataFormTextField Binding="{Binding Title}" FieldLabelContent="Title"/>
<df:DataFormComboBoxField x:Name="AuraList" Binding="{Binding Aura}" FieldLabelContent="Aura"/>
</df:DataForm.Fields>
Code:
public enum Auras
{
Holy,
Fire,
Frost,
}
public class MobDetail : IEditableObject
{
public string Name { get; set; }
public string Title { get; set; }
public Auras Aura { get; set; }
public override string ToString() { return Name; }
public void BeginEdit(){}
public void EndEdit(){}
public void CancelEdit(){}
}
The DataForm ItemsSource is bound to an ObservableCollection()
What do I need to do to populate and initialize the dropdown?
Answer is to use a converter:
and set the ItemsSource on the form Loaded event
See here for the full story:
Creating-Rich-Data-Forms-in-Silverlight-3-Customization