locked
wpf textblock editor RRS feed

  • Question

  • I would like a light weight editor for a textblock.
    Monday, November 2, 2015 8:46 PM

Answers

  • You could make an editable TextBox look like a TextBlock by basically simply removing its Border:

            <TextBox Background="Transparent"
             BorderThickness="0"
             TextWrapping="Wrap" />

    You can then set the IsReadOnly property of the TextBox to true/false to switch between a non-editable "TextBlock" and an editable "TextBlock".

    That's probably as lightweight it gets.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Tuesday, November 3, 2015 4:58 PM

All replies

  • The obvious thing to use for editing a string would be a textbox.


    Hope that helps.

    Technet articles: WPF: MVVM Step 1; All my Technet Articles

    Monday, November 2, 2015 9:01 PM
  • You could make an editable TextBox look like a TextBlock by basically simply removing its Border:

            <TextBox Background="Transparent"
             BorderThickness="0"
             TextWrapping="Wrap" />

    You can then set the IsReadOnly property of the TextBox to true/false to switch between a non-editable "TextBlock" and an editable "TextBlock".

    That's probably as lightweight it gets.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Tuesday, November 3, 2015 4:58 PM
  • Unfortunately this does not give me the font metrics without having to do a separate fmt_text.
    Monday, November 9, 2015 8:43 PM
  • Perhaps it might have been an idea to elaborate your requirements beyond the one line.


    Hope that helps.

    Technet articles: WPF: MVVM Step 1; All my Technet Articles

    Monday, November 9, 2015 8:57 PM