在DataGrid中将TextBlock中的文本显示为HhiperLink

时间:2015-11-24 12:57:24

标签: c# wpf xaml datagrid textblock

我在Log上的项目消息中有:

  

对象错误,ID = {488DB9A2-6C4C-4E06-887E-6D35C6D538CA}

我希望像你看到的那样将这个guid显示为超链接。我用简单的文本和链接创建了TextBlock。

public TextBlock InitTextBlock(string message)
    {
        var textBlock = new TextBlock();
        var strs = ParseByGuid(Message);

        foreach (var str in strs)
        {
            var run = new Run(str.Text);
            if (str.IsLink)
                textBlock.Inlines.Add(new Hyperlink(run));
            else
                textBlock.Inlines.Add(run);
        }
        return textBlock;
    }

但我需要将TextBlock放在DataGrid中,或者可能是另一个控件。

0 个答案:

没有答案
相关问题