0

I have a string with a xaml code inside and I want to know how can I bind this content to a control like TextBlock or Label or other.

My string value is like this :

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf" Style="{StaticResource {x:Static markdig:Styles.DocumentStyleKey}}"> <Paragraph Style="{StaticResource {x:Static markdig:Styles.Heading1StyleKey}}"> <Run Text="Changelog" /> </Paragraph> <Paragraph> <Run Text="All notable changes to this project will be documented in this file." /> </Paragraph> 

The program is returning exactly what I show you.

I hope some one can help me. Perhaps I just don't know how to explain my problem on google

5
  • For searchability, you want to have xaml that is compiled dynamically (or executed or interpreted etc..) Commented Sep 18, 2020 at 14:32
  • Yeah exact, thanks you Commented Sep 18, 2020 at 14:32
  • Does this answer your question? Compile/Execute XAML during program runtime Commented Sep 18, 2020 at 14:33
  • Yeah but I want to do this with the binding Commented Sep 18, 2020 at 14:45
  • You can use xamlreader.parse with a string. Which interally does pretty much what you've written yourself. learn.microsoft.com/en-us/dotnet/api/… Commented Sep 18, 2020 at 15:27

1 Answer 1

0

I convert my string to Stream

 byte[] byteArray = Encoding.ASCII.GetBytes(ChangelogContent); MemoryStream stream = new MemoryStream(byteArray); scrollView.Content = XamlReader.Load(stream); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.