この問題があります。Extended WPF Toolkit から richTextBox コントロールに画像 (笑) を追加します。
単純なテキストを画像付きのテキストに変換する関数で、段落の行の高さを設定し、この段落を richTextBox のブロックに追加します。はい、これ:
private void RpTextToTextWithEmoticons(string msg)
{
//set line height
var para = new Paragraph {LineHeight = 40};
var r = new Run(msg);
para.Inlines.Add(r);
string emoticonText = GetEmoticonText(r.Text);
//if paragraph does not contains smile only add plain text to richtextbox rtb2
if (string.IsNullOrEmpty(emoticonText))
{
RtbConversation.Document.Blocks.Add(para);
}
else
{
while (!string.IsNullOrEmpty(emoticonText))
{
TextPointer tp = r.ContentStart;
// keep moving the cursor until we find the emoticon text
while (!tp.GetTextInRun(LogicalDirection.Forward).StartsWith(emoticonText))
tp = tp.GetNextInsertionPosition(LogicalDirection.Forward);
// select all of the emoticon text
var tr = new TextRange(tp, tp.GetPositionAtOffset(emoticonText.Length)) { Text = string.Empty };
//relative path to image smile file
string path = _mappings[emoticonText];
var image = new Image
{
Source = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute)),
Width = 30,
Height = 30,
};
//insert smile
new InlineUIContainer(image, tp);
if (para != null)
{
var endRun = para.Inlines.LastInline as Run;
if (endRun == null)
{
break;
}
else
{
emoticonText = GetEmoticonText(endRun.Text);
}
}
}
RtbConversation.Document.Blocks.Add(para);
}
}
しかし、新しい段落をブロックに追加すると、すべての段落にさまざまな行の高さ/間隔があります。スカイプでのチャットのような、個々の段落間の行の高さ/間隔を一定にする必要があります。
画像で見ることができる私の問題:
どこに問題があるのか、私は無力です。事前に感謝します。