将原始json绑定到WPF文本块

问题描述 投票:-1回答:1

请帮助我将来自REST API的原始json数据绑定到任何WPF控件。我以为WPF文本块。这是隐藏的代码:

           try
            {
                HttpResponseMessage response = await client.PostAsync(execInfoServiceUrl, httpContent);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var jsonResult = response.Content.ReadAsStringAsync();
                    TxtShowResults.Text = jsonResult.ToString();

                }
            }

这里是xaml代码:

    <WrapPanel>
            <TextBlock x:Name="TxtShowResults" />
    </WrapPanel>

谢谢

json wpf data-binding textblock
1个回答
0
投票

如果要在文本块中显示JSON文件的文本,则应研究与文本块的字符串绑定。这是我在SO上找到的一个:

WPF TextBlock Binding to a String

© www.soinside.com 2019 - 2024. All rights reserved.