55using  CommunityToolkit . Labs . WinUI . MarkdownTextBlock . Renderers ; 
66using  CommunityToolkit . Labs . WinUI . MarkdownTextBlock . TextElements ; 
77using  Markdig ; 
8+ using  Markdig . Syntax ; 
89
910namespace  CommunityToolkit . Labs . WinUI . MarkdownTextBlock ; 
1011
@@ -30,6 +31,12 @@ public partial class MarkdownTextBlock : Control
3031        typeof ( MarkdownTextBlock ) , 
3132        new  PropertyMetadata ( null ,  OnTextChanged ) ) ; 
3233
34+     private  static   readonly  DependencyProperty  MarkdownDocumentProperty  =  DependencyProperty . Register ( 
35+         nameof ( MarkdownDocument ) , 
36+         typeof ( MarkdownDocument ) , 
37+         typeof ( MarkdownTextBlock ) , 
38+         new  PropertyMetadata ( null ) ) ; 
39+ 
3340    public  MarkdownConfig  Config 
3441    { 
3542        get  =>  ( MarkdownConfig ) GetValue ( ConfigProperty ) ; 
@@ -42,6 +49,12 @@ public string Text
4249        set  =>  SetValue ( TextProperty ,  value ) ; 
4350    } 
4451
52+     public  MarkdownDocument ?  MarkdownDocument 
53+     { 
54+         get  =>  ( MarkdownDocument ) GetValue ( MarkdownDocumentProperty ) ; 
55+         private  set  =>  SetValue ( MarkdownDocumentProperty ,  value ) ; 
56+     } 
57+ 
4558    public  event  EventHandler < LinkClickedEventArgs > ?  OnLinkClicked ; 
4659
4760    internal  void  RaiseLinkClickedEvent ( Uri  uri )  =>  OnLinkClicked ? . Invoke ( this ,  new  LinkClickedEventArgs ( uri ) ) ; 
@@ -102,8 +115,8 @@ private void ApplyText(bool rerender)
102115
103116            if  ( ! string . IsNullOrEmpty ( Text ) ) 
104117            { 
105-                 var   markdown  =  Markdown . Parse ( Text ,  _pipeline ) ; 
106-                 _renderer . Render ( markdown ) ; 
118+                 this . MarkdownDocument  =  Markdown . Parse ( Text ,  _pipeline ) ; 
119+                 _renderer . Render ( this . MarkdownDocument ) ; 
107120            } 
108121        } 
109122    } 
0 commit comments