I am trying to make a Universal Windows Platform (UWP) program where I have a RichEditBox that allows me to write Richly Formatted Text for several separate objects. I want to be able to click on an object and then display the text associated with that object.
Click on object -> RichEditBox displays the text in RTF (Rich Text Format) of that object.
Click on another object -> RichEditBox now displays the text belonging to the latest object.
Currently I am only able to hold the input as a string, but this loses the formatting of the input (specifically the colors of the words).
How do I hold my input (keep the data in RAM) in a way that allows me to retain the formatting?
Is there a certain variable type I can use?
Found a solution for the Problem. I need to save the input in the RichEditBox as a InMemoryRandomAccessStream.
public sealed partial class MainPage : Page
{
// The variable to hold the input
Windows.Storage.Streams.InMemoryRandomAccessStream stream =
new Windows.Storage.Streams.InMemoryRandomAccessStream();
public void storeInput()
{
RichEditBox.Document.SaveToStream
(Windows.UI.Text.TextGetOptions.FormatRtf, stream);
}
}