xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.87k stars 871 forks source link

Enable bold font without selection #1491

Open Plan-CollinAlpert opened 5 years ago

Plan-CollinAlpert commented 5 years ago

Hi,

is it possible to enable a bold font without having to select text first? I just want to click the "Bold" button, start typing and see bold text. This only currently works if I select text first, then bake it bold and then continue typing.

Also, I seem to be having massive performance problems. Typing is extremely laggy. Is this a known issue?

Anyways, here's my code:

<DockPanel DockPanel.Dock="Top"
                    LastChildFill="False">
    <Button Content="B"
                  FontWeight="Bold"
                  FontFamily="Times New Roman"
                  Command="EditingCommands.ToggleBold"
                  CommandTarget="{Binding ElementName=TextBlockInstanceContentBox}" />
    <Button Content="I"
                  FontStyle="Italic"
                  FontFamily="Times New Roman"
                  Command="EditingCommands.ToggleBold"
                  CommandTarget="{Binding ElementName=TextBlockInstanceContentBox}"
                  Margin="5 3 5 2" />
    <Button Command="EditingCommands.ToggleUnderline"
                  CommandTarget="{Binding ElementName=TextBlockInstanceContentBox}">
        <TextBlock TextDecorations="Underline"
                          FontFamily="Times New Roman"
                          Text="U" />
    </Button>
</DockPanel>
<xctk:RichTextBox Text="{Binding SelectedTextBlockInstance.Content, Delay=500, UpdateSourceTrigger=PropertyChanged}"
                                                              x:Name="TextBlockInstanceContentBox"
                                                              FontSize="12">
  <xctk:RichTextBox.CommandBindings>
      <CommandBinding Command="EditingCommands.ToggleBold" />
      <CommandBinding Command="EditingCommands.ToggleItalic" />
      <CommandBinding Command="EditingCommands.ToggleUnderline" />
  </xctk:RichTextBox.CommandBindings>
  <xctk:RichTextBoxFormatBarManager.FormatBar>
      <xctk:RichTextBoxFormatBar />
  </xctk:RichTextBoxFormatBarManager.FormatBar>
  <xctk:RichTextBox.ContextMenu>
      <ContextMenu AllowDrop="True">
          <MenuItem Header="Test" />
      </ContextMenu>
    </xctk:RichTextBox.ContextMenu>
</xctk:RichTextBox>

Thanks a lot, Collin

XceedBoucherS commented 5 years ago

Hi, the EditingCommand.ToggleBold is suppose to modify the selected text, as stated here : https://docs.microsoft.com/en-us/dotnet/api/system.windows.documents.editingcommands.togglebold?view=netframework-4.8

Concerning the lag, we didn't found the control to be extremely laggy. Can you submit a sample and the steps to reproduce this ? Could it be related to the Delay in th Binding of 500 ?


Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF