I save my text data in a sqlite database, I am able to store them, read them and etc.
To load it in The app I do something like this in
I guess you cannot store a formatted text in your data base. There is no way for it to what I know. However, you can format your text for the label using the FormattedText
property of the Label and setting FormattedString
.
Refer Xamarin documentation here for more details.
Refer below example code.
<Label LineBreakMode="WordWrap">
<Label.FormattedText>
<FormattedString>
<Span Text="Hello Name, " TextColor="Red" FontAttributes="Bold" />
<Span Text="Welcome to , " Style="{DynamicResource BodyStyle}" />
<Span Text="Xamarin Forms." FontAttributes="Italic" FontSize="Small" />
</FormattedString>
</Label.FormattedText>
</Label>
As of now the only way to store formatted text in your database would be to format it using HTML and save it. You can use the Display HTML feature of Label to render that in UI. Documentation details here.
Refer below code more reference.
<Label Text="This is <strong style="color:red">HTML</strong> text." TextType="Html" />
<Label TextType="Html">
<![CDATA[
This is <strong style="color:red">HTML</strong> text.
]]>
</Label>
If you trying to store and Read a single string into your SQLite DB then use TextType="Html" property in Label control.
like...
<Label Text="{Binding YourViewModelStringProperty}" TextType="Html">
Hello @Riccardo Raffini,
You can store Text in DB like this,
"Neque <strong>porro</strong>
"
then in Xaml Add Text Type to Html,
<Label Text="YourTextHere" TextType="Html">
Hope this helps.