您的位置:首页 > 其它

RichEditBox控件装载并显示RTF文件内容

2014-03-19 21:30 465 查看
环境

[1]Visual Studio 2013

[2]Win Store App 8.1

正文

XAML部分内容

<RichEditBox x:Name="reb" Background="#FF0F243E" BorderThickness="0" Margin="4"/>

C#部分内容

public async Task Model2View()
{
Uri dataUri = new Uri("ms-appx:///Assets/rtf/preface.rtf");//Build Action为Content

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);

if (file != null)
{
Windows.Storage.Streams.IRandomAccessStream randAccStream =
await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

// Load the file into the Document property of the RichEditBox.
reb.Document.LoadFromStream(Windows.UI.Text.TextSetOptions.FormatRtf, randAccStream);
reb.IsReadOnly = true;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: