2

我将图像从 aURL插入到RichEditBox这样的:

// Create a MemoryStream from uri, and insert into richeditbox
System.IO.Stream stream = await new HttpClient().GetStreamAsync("some url");
var memoryStream = new MemoryStream();
await stream.CopyToAsync(memoryStream);
memoryStream.Position = 0;
this.richEditBox.Document.Selection.InsertImage(40, 40, 0, Windows.UI.Text.VerticalCharacterAlignment.Baseline, "image", memoryStream.AsRandomAccessStream());

哪个工作正常,但按下时我无法删除(使用屏幕键盘)图像backspace

有人有想法么?

4

1 回答 1

0

找到了!答案很简单——只需要设置 Selection.StartPosition

this.richEditBox.Document.Selection.StartPosition--;
this.richEditBox.Document.Selection.Delete(Windows.UI.Text.TextRangeUnit.Object, 1);

StartPosition默认情况下设置为EndPositionfor Document.Selection,因此尝试删除只是什么都不做(因为没有选择任何内容)。

注意:覆盖KeyDown事件RichEditBox并将以上内容添加到VirtualKey.Back按键以从屏幕键盘获得所需的结果!

于 2015-05-31T01:46:22.147 回答