WPF> Using RadioButtonList style. I want to display user friendly enum strings. how?
I want to display all the possible enum values as Radio buttons. I am using popular RadioButtonList style to display the radiobutton from my enum using DataProvider in a Listcontrol. I can get all the radio buttons but the text appear with the radio button is not user friendly. I am using the following method.
http://social.msdn.microsoft.com/forums/e开发者_JAVA百科n-US/wpf/thread/5137aabc-bb3a-478a-9438-bc93dd9cc0ac/
I want to show "A ball" instead of "a" and "B ball" instead of "b"
I thought about using converter. But where to use convert. Or any other way to display user friendly values?
As this style is very common, thats why I am not writing whole code. If anything not clear, please ask. I have already invested about 5 hours on this problem.
Change the empty ContentPresenter
to the following binding:
<ContentPresenter>
<ContentPresenter.Content>
<Binding Converter="{StaticResource EnumToUserFriendlyName}"/>
</ContentPresenter.Content>
</ContentPresenter>
Then in the converter you can check the enumerated value and return a more user-friendly name.
精彩评论