Reputation: 371
I have a richtextbox in WPF that allows you to change the text to different colors. Some letters might be red, some might be blue, some might be black, etc. When the user clicks save, it will save the text but not the colors. So when they come back to the page, they get all the correct text, but it all defaults to the color black.
How can I save the state of these colors so that when the user comes back to the page at a later time, the letters will still be the same colors as they left it?
Upvotes: 1
Views: 226
Reputation: 13960
Just save the whole text as a byte array, you don't need to remember echa letter's color. Then, next time, use this method to load the formated text:
rtfBox.Selection.Load(myStreamFromByteArray, DataFormats.Rtf);
http://msdn.microsoft.com/en-us/library/system.windows.documents.textrange.load.aspx
Upvotes: 1