White screen WebView Xamarin.Forms - xamarin

I'm using Xamarin for my application
After I start the application I get a white screen, how can I solve the problem
<StackLayout>
<WebView Source="https://www.radio.md/" x:Name="Browser" VerticalOptions="FillAndExpand" HeightRequest="600"></WebView>
</StackLayout>

Related

syncfusion xamarin form button control, click event not fired on IOS simulator but fired on my IPHONE

I am using syncfusion xamarin form button control on my project, the click event didn't fire on the IOS simulator but fired on both my IPHONE and IPAD. anyone experienced this issue?
the XMAL is attached below,
<buttons:SfButton Padding="10"
x:Name="btnCamera"
Grid.Column="1"
IsCheckable="False"
BackgroundColor="White"
BorderColor="Transparent"
BorderWidth="0"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Clicked="btnCamera_Clicked"
HasShadow="True"
CornerRadius="20">
<buttons:SfButton.Content>
<Image Source="Camera.png"
HeightRequest="45"
WidthRequest="45"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</buttons:SfButton.Content>
</buttons:SfButton>
<buttons:SfButton Padding="10"
x:Name="btnImageFolder"
Grid.Column="3"
IsCheckable="False"
BackgroundColor="White"
BorderColor="Transparent"
BorderWidth="0"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Clicked="btnImageFolder_Clicked"
HasShadow="True"
CornerRadius="20">
<buttons:SfButton.Content>
<Image Source="ImageFolder.png"
HeightRequest="45"
WidthRequest="45"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</buttons:SfButton.Content>
</buttons:SfButton>
Query: StackOverflow : syncfusion xamarin form button control, click event not fired on IOS simulator but fired on my IPHONE
We are unable to replicate the reported issue on our side. We are prepared a sample based on the provided code snippet since the ButtonClick event is properly called on our side. We have prepared a sample and video for your reference. Sample
Please make sure you have added SfButtonRenderer for iOS in the AppDelagates.cs file. Refer to the below link,
Link: https://help.syncfusion.com/xamarin/button/gettingstarted#additional-step-for-ios
Please check and let us know once the problem was resolved on your side.
Regards,
Ruba Shanmugam

Why does Ad Hoc build a different version of a Xamarin app than Visual Studio on Mac?

Here is the landing page for my application:
<ContentView x:Class="ThetaRex.OpenBook.Quant.Forms.Views.MainView"
xmlns:controls="clr-namespace:ThetaRex.OpenBook.Quant.Forms.Controls"
x:DataType="viewModels:MainViewModel"
xmlns:viewModels="clr-namespace:ThetaRex.OpenBook.Quant.Common.ViewModels;assembly=ThetaRex.OpenBook.Quant.Common"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns="http://xamarin.com/schemas/2014/forms">
<StackLayout>
<Label FontSize="Large"
HorizontalOptions="CenterAndExpand"
Margin="20,40,20,10"
Text="{x:Binding WelcomeLabel}"/>
<StackLayout Margin="20,0">
<ListView HasUnevenRows="True"
ItemsSource="{x:Binding Items}"
Margin="20,0">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewModels:FunctionItemViewModel">
<ViewCell>
<controls:DetailButton Command="{x:Binding Command}"
CommandParameter="{x:Binding CommandParameter}"
Description="{x:Binding Description}"
IsEnabled="{x:Binding IsEnabled}"
Label="{x:Binding Label}"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentView>
This is what it looks like when built on a Mac and built on Windows:
I built both using the exact same code and Visual Studio (Mac/Windows), then Archive to file, then load IPA using iTunes.
At no point did I ask for a scrollable window for the main stack layout, but the VS Windows seems to add that capability. Does anyone have a clue what's going on here?

Labels are not visible in Xamarin.iOS

I just recently started Xamarin.Forms. I run the following code by deploying it to my own IPhone device. The code is the default code that is added whenever a new page is added.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TestReal.MainPage">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
The problem is that the label that is supposed to say "Welcome to Xamarin Forms!" doesn't appear. I tried rotating the screen, giving it a bigger padding and margin. Giving it a different background color, foreground color and etc. However a slider or a button is displayed correctly. Just the label is not visible.
I found the solution to the issue. Since the dark mode was on on my IPhone device the text was looking white. When dark mode is turned off I am able to see the label and it works as expected.
Try this: Why won't text on a label show up on an actual device but will in the simulator? (Xcode)

How to embed ZXing scanner in PageRenderer/Fragment/View into Xamarin.Forms ContentPage?

I want to have ZXing.Net.Mobile barcodes scanner with a custom overlay and some UI components implemented in Xamarin.Forms in one View.
Is it possible at all?
I assumed that this is possible and implemented this:
1. Android.Support.V4.App.FragmentActivity with a custom overlay for ZXing scanner.
2. Android Activity with a custom overlay for ZXing scanner.
3. Android PageRenderer with a custom overlay for ZXing scanner.
I was able to run all these variants, but I was not able to mix them with Xamarin.Forms UI.
Example:
Here is my ZXingScannerRendererPage.xaml in the shared project. I want to have "TEST BUTTON" button above Zxing Scanner view.
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage x:Name="RootPage"
BackgroundColor="{StaticResource BackgroundColor}"
xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:DataCollector" x:Class="DataCollector.ZXingScannerRendererPage">
<ContentPage.Content>
<StackLayout>
<Button Text="TEST BUTTON" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
But when I run the application with PageRenderer I can see for a second my layout with "TEST BUTTON" and then view jumps to ZXing scanner.
When I "press back" button, I can see my XAML layout with "TEST BUTTON". I think ZXing opens a new activity or something.
So, what I need is:
1. Embed ZXing.Net.Mobile barcodes scanner with custom overlay into my Xamarin.Forms ContentPage along with other Xamarin.Forms UI.
or
2. Embed Xamarin.Forms UI above view with ZXing.Net.Mobile barcodes scanner with a custom overlay.
How to accomplish this? Is it possible to embed PageRenderer/Fragment/View into Xamarin.Forms XAML?
Thanks!
How to accomplish this? Is it possible to embed PageRenderer/Fragment/View into Xamarin.Forms XAML?
You could embed the scanner view in between to other redundant BoxViews.
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ZXingSample.PartialScreenScanning"
xmlns:zxing="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"
Title="Partial screen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<BoxView Grid.Row="0" BackgroundColor="Chocolate"/>
<zxing:ZXingScannerView Grid.Row="1" x:Name="_scanView" OnScanResult="Handle_OnScanResult" IsScanning="true"
WidthRequest="200" HeightRequest="200" />
<BoxView Grid.Row="2" BackgroundColor="Blue" />
</Grid>
You could download the source file from the GitHub. https://github.com/jfversluis/ZXingSample
This blog would be helpful as well. https://blog.verslu.is/xamarin/xamarin-forms-xamarin/scanning-generating-barcodes-zxing/
I think there is an identical thread in XF forum.
You may find some hints from my reply on it
https://forums.xamarin.com/discussion/176704/how-to-embed-zxing-scanner-in-pagerenderer-fragment-view-into-xamarin-forms-contentpage#latest

ListView GroupHeaderTemplate with fixed height on iOS

I'm trying to set a variable height list view on iOS. Our code (on the sample project linked and main part below) works fine on Droid, but fails miserably on iOS.
I have tried iOS 9.3 and iOS 10, with forms 2.3.2.127 and latest prerelease 2.3.3.163-pre3.
<ListView Grid.Row="2"
ItemsSource="{Binding MenuSections}"
IsGroupingEnabled="True"
HasUnevenRows="True"
SeparatorVisibility="Default"
ItemTapped="ListViewOnItemTapped">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="15,10,15,10"
Spacing="0"
BackgroundColor="Green">
<Label Text="{Binding Name}"
LineBreakMode="TailTruncation"
TextColor="White"
FontSize="14"/>
<Label Text="{Binding Description}"
Margin="0,0,0,10"
IsVisible="{Binding HasDescription}"
LineBreakMode="WordWrap"
TextColor="{StaticResource BSDirtyWhite}"
FontSize="11"/>
</StackLayout>
</ViewCell>
</DataTemplate>
I have already removed everything above with only a Label, and got exactly same result. Looks like header height on iOS is fixed to some constant number.
Please find below the screen shots for Droid (working fine) and failed iOS 9.3 and 10.
Any help or workaround is greatly appreciated.
CodeKnox
Droid perfect header:
iOS 9 broken header:
iOS 10 broken header:
Sample project:
repro xamarin forms project
This bug is tracked on the Xamarin Forms Github site: https://github.com/xamarin/Xamarin.Forms/issues/3769
There is a gist in the comments suggesting creating a custom renderer:
https://gist.github.com/nbevans/a713dc9c77a8f530b6f4f3cd4fad83c2

Resources