private async void FillRichTextBox(string text) { var start = 0; var regex = new Regex("\\$\\[img:[0-9]+\\]\\$"); var paragraph = new Paragraph(); foreach (Match match in regex.Matches(text)) { var imageId = Int32.Parse(Regex.Match(match.Value, @"[0-9]+").Value); System.Diagnostics.Debug.WriteLine(imageId); paragraph.AddText(start, match.Index, text); await paragraph.ReplaceLabelWithImage(imageId); start = match.Index + match.Length; } paragraph.AddText(start, text.Length, text); //App.ViewModel.Blocks.Add(paragraph); RichTextBox.Blocks.Add(paragraph); }