I have downloaded Visual Studio 2022 Professional (preview) version from
MS Document. Also I have followed the other steps to create first sample application using .Net MAUI template after VS installed.
It does create new project with all the required dependency. I have installed Android sdk api v30 and created a simulator as mentioned in the official document.
When I have run the application on Android Emulator it does take a lot time to run and after it loaded properly it shows wrong output. It's just showing two Hello World label, while MainPage.xaml does have button as well but that button is not displayed. I have attached output screenshot here:
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="25" Padding="30">
<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level1"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Label
Text="Current count: 0"
FontSize="18"
FontAttributes="Bold"
x:Name="CounterLabel"
HorizontalOptions="Center" />
<Button
Text="Click me"
FontAttributes="Bold"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center"
BackgroundColor="Orange" TextColor="White"/>
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
WidthRequest="250"
HeightRequest="310"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Does anyone know what is wrong here in the app? I have followed the steps mentioned in the MS Document which I have mentioned in the question.
Related
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
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?
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
Please someone tell me why this markup doesn't fire the tap gesture?
Not working
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
But this one does? And I did followed a very basic implementation from the Microsoft/Xamarin docs on how to add a GestureRecognizer.
If I switch to this markup it works perfect! Everything tested on Android phone 7.0 API 24. I use the latest Xamarin.Forms 3.3.0 pre 3 nuget package.
Working Markup
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
</StackLayout.GestureRecognizers>
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