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

来源:互联网 发布:湖南广电网络控股 编辑:程序博客网 时间:2024/06/05 18:20

环境

[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;            }              }


0 0
原创粉丝点击