chaosmaker
chaosmaker

Reputation: 191

WPF: Editable Radio Button

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

I have made all database connections and bindings successfully and all my Radiobuttons are created 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!

Upvotes: 1

Views: 1100

Answers (2)

fixagon
fixagon

Reputation: 5566

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)

Upvotes: 3

Andrew Hanlon
Andrew Hanlon

Reputation: 7451

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.

Upvotes: 2

Related Questions