I'm working with small wpf app and I need to load enumation into my combo box as possiblities that user might choose when he's adding new product and it looks like this:
my enumeration:
public enum ProductTypeEnum : int
{
Unknown = 0,
[StringValue("Final product for sale")]
FinalProduct = 1,
[StringValue("Ingredient for product")]
Material = 2
}
Here is how it looks in my C# WPF App when I'm fetching values to display it in my combobox:
var myEnums = ProductTypeEnum.GetValues(typeof(ProductTypeEnum));
if(myEnums.Length > 0)
{
cmbArticleType.ItemsSource = myEnums;
//cmbArticleType.DisplayMemberPath = "SOMETHING.. WHATEVER IT AINT WORKED";
}
And this displays as you can see my real values "FinalProduct" and not the "Final product for sale"
[StringValue("Final product for sale")]
and I would like to display Final product for sale because it looks more natural in combobox (with spaces and so) =)
Thanks guys for any kind of help Cheers
EDIT AFTER MM8 HELPS:
How could I get real value out of this, cast it in integer as enums holds value of 0,1,2,3 etc :
But articleType does not provide Value so I could cast it in integer and store to db?