private static void OnNodeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is RichTextBlock rtb && e.NewValue is IAstNode root) { var renderer = new RichTextBlockRenderer(); var res = renderer.Render(root); rtb.Blocks.Clear(); foreach (var item in res) { rtb.Blocks.Add(item); } } }
private static async void OnChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var html = e.NewValue.ToString(); if (d is RichTextBlock rtb) { var renderer = new RichTextBlockRenderer(); var res = await renderer.RenderAsync(html); rtb.Blocks.Clear(); foreach (var item in res) { rtb.Blocks.Add(item); } } }