开发者

WPF> Using RadioButtonList style. I want to display user friendly enum strings. how?

开发者 https://www.devze.com 2022-12-28 04:44 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消