コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
        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);
                }
            }
        }