Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 8 of 8

Thread: Is it just me or do none of the richTextBox controls work properly(WPF)?

  1. #1

    Is it just me or do none of the richTextBox controls work properly(WPF)?

    This is my first post here, normally I just come here to read since there is so much quality info on WPF on the site. Recently though I began working with the rich textbox in a WPF project. This honestly baffles me because it seems like the answer is so simple that Im just missing it.
    I want to be able to open a window with a rich text box in it, click the bold button and begin typing in bold. Yet the only documentation regarding the RTB controls in WPF is how to make selected text bold. You cant throw a rock without hitting a blog or forum that explains or discusses this. Yet I cant find anywhere the C# that applies bold to all of the text. Donít some people actually prefer to first setup the font, wieght, style, etc before they start typing?
    Aftter I read about RTB controls here and downloaded the kWordpad to test out, I actually had to open wordpad myself, click the bold button and start typing (just to see if I was losing my marbles). This is how the native word processors work, but none of the WPF apps containing a rich textbox that I have tested in the past week or so have this feature, but nobody seems to be bothered by this fact.
    So what am I missing?

  2. #2
    That's a good point! I never noticed that, but I will look into it shortly

    Great, now even Kirupa is { facebooking | twittering }

  3. #3
    Thanks man, I really appriciate that. I was feeling pretty lost there for a while, so any insight would be a big help.

  4. #4
    Joe - I just tested out kWordpad (http://www.kirupa.com/forum/showthread.php?t=265975), and it actually works the way you want it to. You can hit the Bold button and begin typing, and all of the text appears in Bold. Is that not what you are seeing?

    Great, now even Kirupa is { facebooking | twittering }

  5. #5
    I never got kWordpad to do this for me. Though after you mentioned it, I went back and took another look. I noticed that if upon opening the window, I clicked on the Bold button first and then went and began typing, the Bold button would return to an unChecked state and my text would not be bold. However if I first clicked once inside of the rich textbox and then clicked the bold button, when I started typing the text would be bold.

    So I went into the source and added: "this.MainRichTextBox.Focus();" directly benieth “InitializeComponent” to the Window1.xaml.cs file, so that the rich textbox would already have been ‘clicked’ upon opening and now it works just like wordpad as far as applying styles.

    Are you getting similar behavior or not? If its working differently for you, is there any chance you know whats happening here?

    Either way, thanks for making me take a second look. And just while I have you on the line, I want to tell you I love the website. The tutorials here are great. Most sites simply give snippits, but don’t give you all of how they achieved this or that feature. So its nice to know that when I start something here, all of the info I need to finish it or get it working is included. I'm looking forward to more in the WPF field.
    Thanks again.




    P.S. Just as a side note I was curious why you have:
    private void SelectDefaultFont()
    {
    FontFamilyCombo.SelectedValue = "Arial";
    }
    in the Window1.xaml.cs file when the Selected Index is already set in Expression Blend (0).

    Just for fun I changed it to: SelectedValue=”Calibri” in the C# file and left the Selected index in Expression Blend at 0. Now when I run kWordpad the combo box has Calibri set as the defualt but resets to Arial as soon as I begin typing in the rich textbox.

    What makes this really odd to me is that if it is being set by the selected index in Expression Blend, then the selected index would have to be set at 9 on my computer in order for it to choose Arial as the default (for me 0 is Abyssinica SIL). So where is it getting Arial from; and how is it that it is ignoring both the SelectedDefaultFont and the SelectedIndex? I realize this may seem tedius, but I just hate not knowing... "to be continued" at the end of a tv show makes me nuts too; I'm seeking help.

  6. #6
    It seems I spoke too soon about having that bold problem tucked away. It does work like I mentioned. However if upon opening the window i first click the bold button then click in the textbox, the bold button will return to its unClicked state. It is only if i first click the bold button and begin typing without clicking in the textbox before typing that it retains its isChecked state and the text is bold.

    (This is how it is working after adding the MainRichTextBox.Focus to the cs file.)

  7. #7
    In case any of the 132 views were genuinely interested individuals, I found that the font family combo box was receiving ‘Arial’ from the “default text” set for the rich textbox in the XAML. Upon opening the application, the comboBox shows the default selected text. It would change to Arial once the user clicks in the rich textbox, because it would then represent the default text of the rtb.

    As for the problem with the font style controls; they still don’t seem to work properly. At this point it feels like I am trying to trick them into working the way we expect them to.

    I think the the check preformed at the beginning of the Window1.xaml.cs file is causing some of the strange behavior. For instance if you open the application, click the bold button and then click in the RTB before you begin actually typing, the bold button will uncheck itself in order to reflect the current unbold state of the RTB (since the default state of the RTB is not bold). So maybe rewording that operation will fix the problem.

    Any thoughts... anybody?

  8. #8
    Hmm interesting! I am completely swamped with other tasks right now, but I'll *try* to look at in greater detail shortly

    Great, now even Kirupa is { facebooking | twittering }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012