开发者

WPF: Editable Radio Button

开发者 https://www.devze.com 2023-03-07 04:21 出处:网络
I need something like \"TextBox like Label\" for \"RadioButton content\". I have made all database connections and bindings successfully and all my Radiobuttons are cr开发者_开发百科eated according t

I need something like "TextBox like Label" for "RadioButton content".

I have made all database connections and bindings successfully and all my Radiobuttons are cr开发者_开发百科eated according to my database information and no problem.

When user adds a new item to the RadioButtons, he/she would be able to change its content until he/she presses enter or focused out. RadioButton content behaves like Label now but somehow I would like to have a TextBox like behaviour to be able to edit it. After editing, its content should continue its default behaviour.

Is there any solution for this using RadioButton (Editing template) or I should think about writing my own Radiobutton with one button and one editable label?

Thanks in advance!


The RadioButton Class extends ContentControl which means, that it has a content which can be defined as you want. So what you can do is just set a editable TextBox as Content of a Radiobutton

example:

<RadioButton>
  <TextBox Text="Test" />
</RadioButton>

didnt implement the editability of the TextBox, this you have to do yourself. but the way to go is to create a usercontrol which manages the content of the related contentcontrol (radiobutton)


This is WPF, why not just compose a Radio button that contains a textbox? You can bind the texbox text to whatever property you would normally bind for the Radio Button value.

0

精彩评论

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