How can we wrap words in a lable in .net maui 7 - c#

Here is the .Net Maui code
<Label x:Name="LblName" FontSize="Default" LineBreakMode="WordWrap" TextColor="White" ></Label>
I'm trying to wrap the text but so far, nothing seems to be working. I've used all of the "LineBreakMode(s)" in conjunction with the "MaxLines".
The data in label is coming from the code behind file using the "LblName".
I've used all of the "LineBreakMode(s)" in conjunction with the "MaxLines".

Related

Concatenating binding data in XAML frontend with .NET maui not working

I am trying to add an "R" in front of my binding variable in my XAML frontend of my .NET maui project.
Below is the line of code:
<Label Text="{Binding FundsTotal, StringFormat=R{0}}" Margin="0, 20, 0, 0" FontFamily="PoppinsRegular" FontSize="35" HorizontalTextAlignment="Center" TextColor="White"></Label>
The String formatting works initially but as soon as I stop and start the project again, the R no longer shows up. Any suggestions?

ActivityIndicator not showing in XAML or CodeBehind

I have a weird situation on my Xamarin.Forms app. I´m trying to show an ActivityIndicator, but it is not showing in any condition. I´ve set all conditions on XAML and then I tried on code behind. But I could not get it to work. This is the code:
<StackLayout HorizontalOptions="Center"
VerticalOptions="Center">
<ActivityIndicator x:Name="actIndicator"
Color="Blue"
IsVisible="True"
IsRunning="True"/>
<Label x:Name="lblCargando"
Text="Cargando..." />
<Label x:Name="lblStatus"/>
<Button x:Name="btnCerrar"
Text="Cerrar"
IsVisible="False"
Clicked="Cerrar_Clicked"/>
</StackLayout>
Is there something missing?.
Thanks.
Finally, it seems that there was an issue with the emulator that was executing an old version of code.
I deleted the emulator and re create it and get rid of the problem.

How to partially cut ViewCell separator line in Xamarin Forms?

I am using ViewCell to create rows in my table settings page. I have a setting to select a Light or Dark theme.
<ViewCell Height="50">
<StackLayout x:Name="darkTheme" VerticalOptions="FillAndExpand" Padding="20,0,20,0">
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand">
<Label Text="Dark" XAlign="Center" FontSize="15"/>
<Label x:Name="darkThemeCheckmark" Text="{x:Static local:FontAwesome.FACheck}" FontFamily="FontAwesome" XAlign="Center" IsVisible="false" FontSize="12" HorizontalOptions="EndAndExpand"/
</StackLayout>
</StackLayout>
</ViewCell>
<ViewCell Height="50">
<StackLayout x:Name="lightTheme" VerticalOptions="FillAndExpand" Padding="20,0,20,0">
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand">
<Label Text="Light" XAlign="Center" FontSize="15"/>
<Label x:Name="lightThemeCheckmark" Text="{x:Static local:FontAwesome.FACheck}" FontFamily="FontAwesome" XAlign="Center" IsVisible="false" FontSize="12"/>
</StackLayout>
</StackLayout>
</ViewCell>
Whenever I switch from dark to light theme, there is faint light line on the left side between my rows that I can't seem to get rid of. Please refer to the images below:
In my renderer I have set the following:
tableView.LayoutMargins = new UIEdgeInsets() { Left = 20 };
cell.SeparatorInset = new UIEdgeInsets() { Left = 20 };
cell.LayoutMargins = new UIEdgeInsets() { Left = 20 };
Anyone knows how to get rid of this line?
Edit:
I wanted it to look like below:
I am novice to xamarin but, According to this post you need to do this on the UITableView and on your UITableViewCell subclasses.
I hope this will help you. :)
Apologies in advance incase you have already considered this but I believe what you're looking for is 'TableView.SeparatorInset' this would apply to your renderer rather than the xaml your using in your PCL. You can find the documentation around styling the tableviews at this link.
E.G.
TableView.SeparatorInset.InsetRect(new CGRect(4, 4, 150, 2));
Moving the inset of the seperator will get around the problem I saw you mention in the comments of the other answer about the whole table shifting. Please let me know if you've tried this already, it's the simplest solution but there are other options available to you. (They just aren't as nice).
Edit: Example of a way of achieving your goals by creating your own seperators, not my favourite but would also resolve the issue you've highlighted as you'd have complete control over the styling of a seperator. Refer to this Link

Button's Background in Xaml UWP

in a UWP application I have a button its Background property is set to "DeepPink", but whenever I hover my mouse over it, it changes to gray (the default color),
here is my code:
<Button Content="Hello World" Margin="100,0,0,0" Background="DeepPink"/>
Am I missing something??
That only defines the default state of the button, not the hover state.
You can either create a custom control template (you can see an example here), or go the easy way of changing colors with Lightweight styling - I'd recommend the second!
The best alternative would be to create Buttons like UI using Frame and Label. In this case, the background color will remain the same.
Example:
<Frame Padding="8" WidthRequest="100" HasShadow="False" BorderColor="Gray"
HorizontalOptions="Center">
<Label Text="Button" HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>

Xamarin forms change SwichCell Text Color

Is it possible to change the text color of xamarins SwichCell ?
At the moment the text in my SwichCell is colored gray, and I want to change it to black.
My xaml looks like this:
..
<TableView Intent="Data" >
<TableRoot>;
<TableSection>
<SwitchCell Text="Allow Push Notifications"/>
</TableSection>
<TableSection>
<ViewCell>
<ViewCell.View>
<Button Grid.Column="1" Text="Log Out" Clicked="LogOutButtonClick" Margin="-20,-20,-20,-20"/>
</ViewCell.View>
</ViewCell>
</TableSection>
<TableSection>
<TextCell Text="Android Version 1.2.1" TextColor="Black"/>
</TableSection>
</TableRoot>
</TableView>
The only thing regarding this I found here but the example is only for IOS and the other provided solutions uses TextCell and Swich combination, which does not fit my scenario (I think)
Someone has linked a stackoverflow answer regarding Swich here. But it does not work for my situacion since I'm using SwichCell and it does not have the properties that are listed in that answer(also it only has an android version)
If the SwitchCell doesn't expose a BackgroundColor Property, you can just wrap the Switch Control in its own ViewCell.
Can't Confirm the syntax, but something like this:
<ViewCell>
<StackLayout>
<Switch BackgroundColor="Black"/>
</StackLayout>
</ViewCell>

Categories