【问题标题】:How can I interpret my string content in WPF control?如何在 WPF 控件中解释我的字符串内容?
【发布时间】:2020-09-18 14:28:57
【问题描述】:

我有一个 string,里面有一个 xaml 代码,我想知道如何将此内容绑定到 TextBlockLabel 或其他控件。

我的字符串值是这样的:

<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>

程序返回的正是我向您展示的内容。

我希望有人可以帮助我。也许我只是不知道如何在 google 上解释我的问题

【问题讨论】:

标签: c# wpf


【解决方案1】:

我将我的字符串转换为流

        byte[] byteArray = Encoding.ASCII.GetBytes(ChangelogContent);
        MemoryStream stream = new MemoryStream(byteArray);
        scrollView.Content = XamlReader.Load(stream);

【讨论】:

    猜你喜欢
    • 2016-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    相关资源
    最近更新 更多