My TextBlocks contains formatting like this...
<TextBlock.Inlines>
<Run x:Uid="Run1" FontWeight="Bold" FontSize="14" Text="This is UWP TextBlock Example. " />
<Run x:Uid="Run2" FontStyle="Italic" Foreground="Red" Text="This is red text. " />
</TextBlock.Inlines>
I have indicated the Runs inside my Resource file as...
Run1.Text = "This is UWP TextBlock Example."
Run2.Text = "This is red text."
... but it is not getting picked up by the Multilanguage Translation tool. How can I get correct translation without the formatting getting broken?
Related
I am currently working on a UI for an application and I want to align the following label Text automatically horizontally, so I wanted to test, how I can align text normally.
The Label Documentation of Maui state, that I have to do it with the HorizontalTextAlignment Element. I tried it several times and it worked, but here it won't:
<CollectionView Grid.Row="1" BackgroundColor="Black">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type models:MessageModel}">
<models:MessageModel Message="Hallo" Created="01.01.2001 00:00:00"/>
<models:MessageModel Message="Hey na!" Created="01.01.2001 00:00:00"/>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:MessageModel">
<Label HorizontalTextAlignment="End" TextColor="White" Text="{Binding Created}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
The Output is the following (And yeah I could use one Label, but I wanted to try both ways):
Edit: adding the following Element HorizontalOptions="FillAndExpand" at the label + a Background Color:
Edit2:
When I change the font in a TextBox control (Arial in my case) it always uses the narrow version of the font with no ability to override (although the FontStretch property is set to Normal).
This is the case for all fonts with multiple stretch versions. It always picks the condensed font. Changing the font weight works as expected.
I have also tried to create a minimum template for the TextBox, but that doesn't help either.
Reproduced this in a new project with only a few lines of XAML:
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="Arial" FontFamily="Arial" FontSize="32" />
<TextBox Text="Arial" FontFamily="Arial" FontSize="32" FontStretch="Normal" Margin="0 20 0 0" Width="300" />
</StackPanel>
Tried with SDK 17763, 17134, 16299 and 15063.
Hopefully this makes sense, as it's quite bizarre to me.
Essentially the problem I have is Font Awesome appears to override certain words with icons which I do not want happening - this is all done in XAML. I only want to use Font Awesome if I'm referencing the unicode directly otherwise I want to see the word I actually type.
I'm not entirely sure how to get around this right now, as any reference I find between Xamarin Forms and Font Awesome online it's generally people struggling to get FA working; which is not my current issue.
<Button Style="{StaticResource FontAwesome}" Text=" Sort By" />
Following the code above, I expect to ONLY see the SortBy icon at the start of my Text property - where I reference the code starting & and ending ;
This works fine - however I also get the same icon when I type "Sort", which I do not want.
EDIT
I've decided to use a Frame to get around this minor issue.
<Frame BackgroundColor="#f99000" HasShadow="False" Margin="5, 10" Padding="10">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnSortBy" />
</Frame.GestureRecognizers>
<StackLayout Orientation="Horizontal">
<Label Style="{StaticResource FALIExtendedWhite}" Text="" VerticalTextAlignment="Center" HorizontalOptions="End" />
<Label Text="Sort By" VerticalTextAlignment="Center" HorizontalOptions="CenterAndExpand" TextColor="White" />
</StackLayout>
</Frame>
I have a text in my resource dictionary:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="ResourceDictionaryName" Localization.Comments="$Content(DoNotLocalize)">Loc-en-EN</system:String>
<!--MainControl.xaml-->
<system:String x:Key="PersonalEmail">Please enter your email./system:String></ResourceDictionary>
and I bind it to xaml this way:
<TextBlock Text="{DynamicResource PersonalEmail}" Style="{DynamicResource TextBlockStyle}"/>
Is it possible to create style or converter, to show, for example, Please bold, and rest of the text as normal?
String itself does not support rich text format, you can use a Span to show the text.
<TextBlock>
<Span>
<Bold>Please</Bold> enter your email.
</Span>
</TextBlock>
And you can put almost anything into a ResourceDictionary and give it a key, and reference it using that key.
<Window.Resources>
<Span x:Key="PersonalEmail">
<Bold>Please</Bold> enter your email.
</Span>
</Window.Resources>
<Grid>
<TextBlock>
<StaticResource ResourceKey="PersonalEmail" />
</TextBlock>
</Grid>
I have a TextBlock and TextBox wrapped within a grid. It's purpose is to allow users to add notes to a task that they are assigned to.
When adding a note to a task, unless the first line of the notes field is clicked in. The notes field does not appear to become active and appears to be read only. The operator should be able to click anywhere in the notes boundary and the field become active.
I thought it might have been something to do with "rowspan" or the binding I have but they seem to be fine.
Any ideas?
<!--Notes-->
<TextBlock
Grid.RowSpan="2"
Text="Notes"
FontWeight="Bold"
Margin="0 5 0 0" />
<TextBox
x:Name="UxNotesField"
Grid.Row="5"
Text="{Binding TaskAction.Notes, Mode=TwoWay, Converter={StaticResource EmptyStringToNullConverter}}"
AcceptsReturn="True"
MaxHeight="200"
TextWrapping="Wrap"
TextChanged="TextBox_TextChanged"
Margin="0 0 5 5"
sec:PermissionsAssistant.PermissionKeysProperty="EditNotesField" />