Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'd use a RUN inside of the RichTextBox, something like:</p> <pre><code>&lt;RichTextBox&gt; &lt;Run FontFamily="Arial"&gt;My Arial Content&lt;/Run&gt; &lt;Run FontFamily="Times" FontWeight="Bold"&gt;My bolded Times content&lt;/Run&gt; &lt;Run&gt;My Content that inherits Font From the RTB&lt;/Run&gt; &lt;/RichTextBox&gt; </code></pre> <p>Ok, This gets to play with some low-level doo hickies. But here we go:</p> <p>First, add a few ToggleButtons and a RichTextBox to a XAML Form. In the Rich Text Box, you'll give it a few Command Bindings in order to let the system know that everything works together.</p> <p>Here's the XAML:</p> <pre><code>&lt;RichTextBox Height="119" Name="RichTextBox1" Width="254" &gt; &lt;RichTextBox.CommandBindings&gt; &lt;CommandBinding Command="EditingCommands.ToggleBold" CanExecute="CommandBinding_CanExecute" &gt;&lt;/CommandBinding&gt; &lt;CommandBinding Command="EditingCommands.ToggleItalic" CanExecute="CommandBinding_CanExecute" &gt;&lt;/CommandBinding&gt; &lt;/RichTextBox.CommandBindings&gt; &lt;/RichTextBox&gt; &lt;ToggleButton MinWidth="40" Command="EditingCommands.ToggleBold" Height="23" HorizontalAlignment="Left" Name="Button1" VerticalAlignment="Top" Width="75" CommandTarget="{Binding ElementName=RichTextBox1}" &gt;Bold&lt;/ToggleButton&gt; &lt;ToggleButton MinWidth="40" Command="EditingCommands.ToggleBold" Height="23" HorizontalAlignment="Left" Name="Button2" VerticalAlignment="Top" Width="75" CommandTarget="{Binding ElementName=RichTextBox1}" &gt;Italics&lt;/ToggleButton&gt; </code></pre> <p>Now, what's there is a RichTextbox, and two toggle buttons, and the togglebuttons are related to the commandbindings to ToggleBold/ToggleItalics individually.</p> <p>In the CODE side, I have these two methods:</p> <pre><code>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) End Sub Private Sub CommandBinding_CanExecute(ByVal sender As System.Object, ByVal e As System.Windows.Input.CanExecuteRoutedEventArgs) e.CanExecute = True End Sub </code></pre> <p>The BUTTON CLICK event handler is there because a button needs the event handler to be usable.</p> <p>The CanExecute tells the button if the value is available for bolding or not (for example, you could check the length, and not attempt to bold if the RTB is empty). </p> <p>Now, for really low-level control of things, you're going to have to be doing things in the RichTextFormat. Follow this <a href="http://www.devcity.net/PrintArticle.aspx?ArticleID=356" rel="nofollow noreferrer">link</a> to find out more about that. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload