大胆,TextBlock的内联,超链接的集合? [英] Bold,Inlines, hyperlink collections of textblock?

查看:171
本文介绍了大胆,TextBlock的内联,超链接的集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取代码:

results.senselist += "\n" + sense_list + Orth + gramGroup + "\n";
<TextBlock Text="{Binding senselist"}></TextBlock>



我要gramGroup是超链接和其他颜色和sense_list大胆或内联。

I want gramGroup is hyperlink and other color and sense_list is bold or Inlines.

我们希望,所有的代码。

Hopefully, All in code.

推荐答案

您需要在您的XAML来定义内联你需要和绑定化子性质

You need to define the Inlines in your xaml as you need and bind the propeties.

<TextBlock>
    <TextBlock.Inlines>
        <Run Text="{Binding PlainText1}"></Run>
        <Hyperlink>
            <TextBlock Text="{Binding LinkText}"></TextBlock>
        </Hyperlink>
        <Run Text="{Binding PlainText2}"></Run>
        <Run Text="{Binding ColorText}" Foreground="Red"></Run>
    </TextBlock.Inlines>
</TextBlock>



的DataContext 可以

public class MyDataContext
{
    public MyDataContext()
    {
        PlainText1 = "This is";
        LinkText = "some link";
        PlainText2 = "with text";
        ColorText = "and red color :)";
    }

    public string LinkText { get; set; }
    public string ColorText { get; set; }
    public string PlainText1{ get; set; }
    public string PlainText2 { get; set; }
}

在屏幕,呈现如下

Which renders in screen as follows

我错过了在问题中的加粗部分。这仅仅是一个设定粗细=大胆的TextBlock

I missed out the bold part in the question. It is just a matter of setting FontWeight="Bold" in your TextBlock.

这篇关于大胆,TextBlock的内联,超链接的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆