Silverlight doesn’t have any kind of ObjEctDataProvider with it. So the famous example of binding the controls with an ObjectDataProvider doesn’t work with silverlight as it works with WPF
<UserControl.Resources>
<ObjectDataProvider MethodName=“GetValues” ObjectType=”{x:Type sys:Enum}“ x:Key=“AlignmentValues”> <ObjectDataProvider.MethodParameters>
<x:Type TypeName=“HorizontalAlignment” />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
This can be done via code behind in the Silverlight. Just add a reference to the Reflection assembly.
using System.Reflection;
Use this simple function to get IEnumerable collection out of Enum type.
public IEnumerable<Enum> GetEnumValues(Enum enumeration)
{
return from gField in enumeration.GetType().GetFields(BindingFlags.Static | BindingFlags.Public)
select (Enum)gField.GetValue(enumeration);
}
Just bind the results of this function with your control and its done !
ComboFrom.ItemsSource = GetEnumValues(new SehajService.Currency());

Nice dispatch and this enter helped me alot in my college assignement. Thanks you seeking your information.
Just what i’ve been looking for – BUT, I dont understand what you apss to the GetEnumValues() function. In the example you use new SehajService.Currency(), but I have a simple enum. How do i convert this into an acceptable Enum type for the parameter?
OK, it can be simplified a bit:-
public IEnumerable GetEnumValues(Type enumType)
{
return from gField in enumType.GetFields(BindingFlags.Static | BindingFlags.Public)
select (Enum)gField.GetValue(enumType);
}
and then the function is called simply by:-
cbEventTypes.ItemsSource = GetEnumValues(typeof(CONDITIONAL_EVENT_TYPE));
although it might benefit from some checks in the GetEnumValues function to ensure that the type passed actuall is an enum.
Good brief and this mail helped me alot in my college assignement. Thank you for your information.
Your blog is very beautiful, can you tell me how to make.
hey your blog design is very nice, neat and fresh and with updated content, make people feel peace and I always enjoy browsing your site.
- Norman
I should digg your post therefore more folks can look at it, very helpful, I had a hard time finding the results searching on the web, thanks.
- Murk
good points and the details are more precise than somewhere else, thanks.
- Thomas
Great blog post, I have been after that…
Darrell
One again, your idea is very
good.thank you!very much.
Lovely! Very well-done!