Note that there are some explanatory texts on larger screens.

plurals
  1. POremove bulletstyle on WPF richtextbox selection
    primarykey
    data
    text
    <p>I've managed to applying bulleted list formatting possible, but how to remove it again? How to detect if the selection is/contains a <code>List</code>? Did I overcomplicate things? Is there a straightword way to convert a selection to a bulleted list and back?</p> <pre><code> Private Sub bullet(o As Windows.Forms.ContextMenuStrip, e As Windows.Forms.ToolStripItemClickedEventArgs) Dim lst As New Windows.Documents.List() lst.MarkerStyle = bullets(e.ClickedItem.Text) If rtf.Selection.IsEmpty Then lst.ListItems.Add(New Windows.Documents.ListItem()) Else Dim li As Windows.Documents.ListItem Dim lines() As String = rtf.Selection.Text.Split(vbCrLf) For Each s As String In lines li = New Windows.Documents.ListItem() li.Blocks.Add(New Windows.Documents.Paragraph(New Windows.Documents.Run(s.Trim()))) lst.ListItems.Add(li) Next rtf.Selection.Text = "" End If Dim curCaret = rtf.CaretPosition Dim curBlock = rtf.Document.Blocks.Where(Function(x) x.ContentStart.CompareTo(curCaret) = -1 AndAlso x.ContentEnd.CompareTo(curCaret) = 1).FirstOrDefault() rtf.Document.Blocks.InsertAfter(curBlock, lst) Dim vMove As Windows.Documents.TextPointer = Nothing vMove = curCaret.GetNextInsertionPosition(Windows.Documents.LogicalDirection.Forward) If vMove IsNot Nothing Then rtf.CaretPosition = vMove rtf.Focus() End Sub </code></pre> <p>I've since come to drop this code from my project because it's unreliable in certain situations. Would a solution based on dynamic XAML insertion be more reliable? Many aspects of WPF seem to very poorly conceived....</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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