Posts

Showing posts from June, 2018

UWP: Storing and retrieving composite application data

Image
You can store and retrieve composite application data in a UWP project using the Windows Storage. Specifically you will be using the Windows.Storage.ApplicationDataCompositeValue sealed class shown in the Object Browser. ObjBrowser.png In this post a project is described where in a pair of values are stored in the Windows Storage's local folder and retrieved. The values are stored using a button click event of a button and retrieved into text boxes in the click event of a second button. The MainPage.xaml for the project is as shown. MainPageXaml.png The code for storing and retrieving is shown in the MainPageXAMLCs. You first define the local settingss using the Windows.Storage.ApplicationDataContainer and the local folder . The composite values are set to the local settings. The retrieving is by extracting the values in the local settings and reading it into a text box. The result of running the application is shown here. The code can be simplified as

UWP: Better use XAML's RichTextBlock than a TextBox for neat rendering of text?

Image
I wanted to disaply in my app a somewhat large amount of text contained in three paragaphs. Using a textbox with wrapping and scrolling did show all the text. However, as displayed text it was not satisfactory. Using 'paragraphs' inside 'RichTextBlock' provided the best option. The XAML code shows a TextBox and a RichTextBlock with three ' Paragraph ' controls. Both of them inside a ' ScrollViewer ' which makes it easy to scroll the text as shown. Here is the code for the MainPage.XAML This is the result rendered in the Local Machine. This one rendered to an emulator (4")