I have very tied to find out the reason of unexpectedly closing of my xamarin android project. I have used CarouselView in xaml page. When I am navigate to that page application is crashed unexpectedly but it works fine when I run ios project. Actually I am working on portable project. Can you please suggest any idea of this issue. I have posted the my hockeyapp crash report. I think it will help to identify, what the exact cause.Thanks in advance.
Here is hockey app crash report
Here is my code
<cv:CarouselView VerticalOptions = "FillAndExpand" HorizontalOptions =
"FillAndExpand" Position = "{Binding DishCategory}" ItemSelected =
"OnSwipeDishesHandler" ItemsSource = "{Binding RestaurantDishesList}"
x:Name = "RestaurantDishesList">
<cv:CarouselView.HeightRequest>
<OnIdiom x:TypeArguments ="x:Double" Phone ="230" Tablet ="630"/>
</cv:CarouselView.HeightRequest>
<cv:CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout Padding = "10,5,10,5" Orientation = "Vertical">
<ListView x:Name="RestaurantMenuListView" BackgroundColor="Transparent" ItemsSource="{Binding CategoryWiseDishes}" HasUnevenRows="true" SeparatorColor="#eeeeee" ItemTapped="OnItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="7">
<Grid Padding="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackLayout Grid.Column="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="OnMenuItemSelected"/>
</StackLayout.GestureRecognizers>
<Label Text="{Binding Name}" TextColor="Black">
<Label.FontSize>
<OnIdiom x:TypeArguments ="x:Double" Phone ="15" Tablet ="20"/>
</Label.FontSize>
</Label>
<Label Text="{Binding Description}" TextColor="#323232">
<Label.FontSize>
<OnIdiom x:TypeArguments ="x:Double" Phone ="11" Tablet ="16"/>
</Label.FontSize>
</Label>
<StackLayout Orientation="Horizontal">
<Label Text="£" TextColor="Black">
<Label.FontSize>
<OnIdiom x:TypeArguments ="x:Double" Phone ="14" Tablet ="19"/>
</Label.FontSize>
</Label>
<Label Text="{Binding Cost}" TextColor="Black">
<Label.FontSize>
<OnIdiom x:TypeArguments ="x:Double" Phone ="14" Tablet ="19"/>
</Label.FontSize>
</Label>
</StackLayout>
</StackLayout>
<StackLayout Grid.Column="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Image Source="minus.png">
<Image.WidthRequest>
<OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
</Image.WidthRequest>
<Image.HeightRequest>
<OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
</Image.HeightRequest>
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="RemoveItemBtnClicked"/>
</Image.GestureRecognizers>
</Image>
<Label Text="{Binding TotalQuantity}" HorizontalOptions="Center" VerticalOptions="Center" TextColor="Black">
<Label.FontSize>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="13" Android="13" WinPhone="13" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="15" Android="15" WinPhone="15" />
</OnIdiom.Tablet>
</OnIdiom>
</Label.FontSize>
</Label>
<Image Source="add.png">
<Image.WidthRequest>
<OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
</Image.WidthRequest>
<Image.HeightRequest>
<OnIdiom x:TypeArguments ="x:Double" Phone ="25" Tablet ="35"/>
</Image.HeightRequest>
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="AddItemBtnClicked"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
</Grid>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</DataTemplate>
</cv:CarouselView.ItemTemplate>
</cv:CarouselView>
Related
Having trouble with using a font. Works fine when I to the following down below.
FontFamily="{StaticResource IconFonts}" Text=""
But it doesn't work if I try to dynamically bind the text property.
FontFamily="{StaticResource IconFonts}" Text="{Binding Comments}"
It shows up all weird. It looks like it tries to do something but doesn't completely render. Here is the full code with my testing included down below. Thanks in advance.
<FlexLayout x:Name="FlexFood"
Wrap="Wrap"
Direction="Row"
JustifyContent="Start"
Padding="0, 10"
BindableLayout.ItemsSource="{Binding FoodCollection}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Padding="5, 0">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTypesSelected"></TapGestureRecognizer>
</Frame.GestureRecognizers>
<Frame.Content>
<StackLayout x:Name="LayoutFood">
<StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
<Label x:Name="LabelTitle" Padding="0, 10">
<Label.FormattedText>
<FormattedString>
<Span FontSize="Subtitle" Text="{Binding Title}" FontAttributes="Bold"></Span>
<Span Text=" "></Span>
<Span FontSize="Subtitle" Text="{Binding Version}" FontAttributes="Bold"></Span>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<StackLayout HorizontalOptions="StartAndExpand">
<Label Text="{Binding Description}" FontSize="Body"></Label>-->
<Label FontSize="Caption" TextColor="#LELELE">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding fDepartment}"></Span>
<Span Text="{Binding pType}"></Span>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
<StackLayout HorizontalOptions="End">
<Label Text="{Binding Comments}"></Label>
<Label FontFamily="{StaticResource IconFonts}" Text=""></Label>
<Label x:Name="LabelTypeTest" FontFamily="{StaticResource IconFonts}"
Text="{Binding Comments, StringFormat=''}"></Label>
<Label FontFamily="{StaticResource IconFonts}" Text="{Binding Comments}"></Label>
<Image x:Name="ImageTypeTest">
<Image.Source>
<FontImageSource Size="48" FontFamily="{StaticResource IconFonts}" Color="#000000"></FontImageSource>
</Image.Source>
</Image>
</StackLayout>
</StackLayout>
</StackLayout>
</Frame.Content>
</helper:LayoutGradient>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
Here is the static resource in app
<ResourceDictionary>
<OnPlatform x:Key="IconFonts" x:TypeArguments="x:String">
<On Platform="iOS" Value="Material Design Icons"></On>
<On Platform="Android" Value="IconFonts.ttf#Material Design Icons"></On>
<On Platform="UWP" Value="/Assets/IconFonts.ttf#Material Design Icons"></On>
</OnPlatform>
</ResourceDictionary>
You should return the escape sequence of \uf139 from your binding instead of
You can read the Access from Bindings and Access Directly in XAML section in the source link for more information.
Refer: xamarin-forms-fontawesome-doesnt-work-with-bound-properties
I am using xamarin with visual studio for IOS and Android
I am trying to add a scrollView to the same grid row that my Frame is on but because the frame is the same size as my grid row it cuts off the bottom of the frame (I believe)
What I've tried :
1. Setting the RowDefinition to "*" and "Auto" but the frame increases the length with the grid and
2. Adjusting the scrollView height
I feel like my best option would be resizing the frame so it's smaller than the grid row, however heightRequest doesn't work.. I would love any suggestions.
Here is the code:
<Grid HeightRequest="400">
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="130"/>
<RowDefinition Height="60"/>
<RowDefinition Height="20"/>
<RowDefinition Height="300"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ScrollView Orientation="Horizontal" Grid.Row="4" Margin="0,20,0,0" HeightRequest="390" HorizontalScrollBarVisibility="Never">
<StackLayout Orientation="Horizontal" Grid.Row="4" BackgroundColor="Red">
<Frame WidthRequest="200" HeightRequest="300" Padding="0,0,0,0" CornerRadius="10" IsClippedToBounds="True" Margin="15,0,0,0">
<StackLayout>
<Image Source="satayChicken.jpg" WidthRequest="200" HeightRequest="200" Aspect="AspectFill"></Image>
<Label Text="Satay Chicken" FontSize="24" TextColor="#48b67b" HorizontalOptions="Center" Margin="0,-5,0,0"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="PREP TIME" FontSize="12" TextColor="#4a6356" />
<Label Text="COOK TIME" FontSize="12" TextColor="#4a6356" Margin="5,0,0,0"/>
</StackLayout>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="0,-10,0,0">
<Label Text="5 mins" FontSize="14" TextColor="#48b67b" />
<Label Text="12 mins" FontSize="14" TextColor="#48b67b" Margin="15,0,0,0"/>
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
</ScrollView>
</Grid>
<StackLayout Orientation="Horizontal" Grid.Row="4" BackgroundColor="Red">
as you have defined the StackLayout Orientaition="Horizontal",the Frame will fill the height by default.
if you want to resize the Frame height,you sholud set its VerticalOptions property
like :
<ScrollView Orientation="Horizontal" Grid.Row="4" Margin="0,20,0,0" HorizontalScrollBarVisibility="Never">
<StackLayout Orientation="Horizontal" BackgroundColor="Red" >
<Frame VerticalOptions="CenterAndExpand" HeightRequest="270" WidthRequest="200" Padding="0,0,0,0" CornerRadius="10" IsClippedToBounds="True" Margin="15,0,0,0">
<StackLayout>
<Image Source="satayChicken.jpg" WidthRequest="200" HeightRequest="200" Aspect="AspectFill"></Image>
<Label Text="Satay Chicken" FontSize="24" TextColor="#48b67b" HorizontalOptions="Center" Margin="0,-5,0,0"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="PREP TIME" FontSize="12" TextColor="#4a6356" />
<Label Text="COOK TIME" FontSize="12" TextColor="#4a6356" Margin="5,0,0,0"/>
</StackLayout>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="0,-10,0,0">
<Label Text="5 mins" FontSize="14" TextColor="#48b67b" />
<Label Text="12 mins" FontSize="14" TextColor="#48b67b" Margin="15,0,0,0"/>
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
</ScrollView>
The specific size is set according to your requirements.
or you also could set Padding property to the StackLayout to resize the Frame location like:
<StackLayout Padding="0,10,0,10" Orientation="Horizontal" Grid.Row="4" BackgroundColor="Red">
<Frame WidthRequest="200" HeightRequest="300" Padding="0,0,0,0" CornerRadius="10" IsClippedToBounds="True" Margin="15,0,0,0">
<StackLayout>
<Image Source="satayChicken.jpg" WidthRequest="200" HeightRequest="200" Aspect="AspectFill"></Image>
<Label Text="Satay Chicken" FontSize="24" TextColor="#48b67b" HorizontalOptions="Center" Margin="0,-5,0,0"/>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="PREP TIME" FontSize="12" TextColor="#4a6356" />
<Label Text="COOK TIME" FontSize="12" TextColor="#4a6356" Margin="5,0,0,0"/>
</StackLayout>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" Margin="0,-10,0,0">
<Label Text="5 mins" FontSize="14" TextColor="#48b67b" />
<Label Text="12 mins" FontSize="14" TextColor="#48b67b" Margin="15,0,0,0"/>
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
I am not sure whether this is my problem or a problem with Xamarin.
On an iPad my application can load the page which contain a list of data in ListView.
The View Cell inside the ListView can be slightly complex. It contains a profile image, some smaller icons using, which are using FFImageLoading.
On iPad, when I tap a cell of the first page to go into the next page, which contains a list of data, it loads very smoothly.
On Android, when I tap on a cell to go into the next page, the detection of the tap is slow and the loading time of the ListView also very slow.
Is there anyway enhance the performance? I thought it was the data I loaded from SQLite. However, after I comment out the ItemsSource on ListView, the loading time is fine.
This is the datatemplate I've used for displaying the cell.
<ViewCell>
<ViewCell.View>
<StackLayout Spacing="0" Padding="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" Spacing="10" Padding="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand">
<controls:CircleImage
Style="{StaticResource profileImageStyle}"
Margin="10, 10, 10, 10"
Source="{Binding Source}"
BorderColor="White"
BorderThickness="2"
VerticalOptions="Center"
HorizontalOptions="Center">
<controls:CircleImage.GestureRecognizers>
<TapGestureRecognizer Tapped="OnChildDetailTapped" />
</controls:CircleImage.GestureRecognizers>
</controls:CircleImage>
<StackLayout VerticalOptions="Fill" Spacing="1" Padding="0,20,0,10" HorizontalOptions="StartAndExpand">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="OnChildDetailTapped" />
</StackLayout.GestureRecognizers>
<StackLayout
Orientation="Vertical"
VerticalOptions="Center"
HorizontalOptions="StartAndExpand">
<Label x:Name="childName" Text="{Binding DisplayName}" Style="{StaticResource normalFont}"> </Label>
<local:ChildInfoIconsView
Child="{Binding .}"
VerticalOptions="Fill">
</local:ChildInfoIconsView>
<Label
x:Name="childNotes"
Style="{StaticResource footnoteFont}"
Text="{Binding ChildNotes, StringFormat={x:Static local:AppResources.formatNotes}}"
IsVisible="{Binding HasChildNotes}">
</Label>
<Label
x:Name="noPickupReason"
Style="{StaticResource footnoteFont}"
Text="{Binding NoPickupReason, StringFormat={x:Static local:AppResources.formatNoPickupReason}}"
IsVisible="{Binding HasNoPickupReason}">
</Label>
<Label
x:Name="absentReason"
Style="{StaticResource footnoteFont}"
Text="{Binding AbsentReason, StringFormat={x:Static local:AppResources.formatAbsentReason}}"
IsVisible="{Binding HasAbsentReason}">
</Label>
</StackLayout>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" HorizontalOptions="End">
<StackLayout.Padding>
<OnIdiom x:TypeArguments="Thickness">
<OnIdiom.Phone>5, 20, 10, 20</OnIdiom.Phone>
<OnIdiom.Tablet>10, 30, 30, 30</OnIdiom.Tablet>
</OnIdiom>
</StackLayout.Padding>
<Image
Style="{StaticResource listviewButtonStyle}"
IsVisible="{Binding EnabledSigning, Source={x:Reference page}}"
Source="ic_action_yes.png"
VerticalOptions="FillAndExpand"
HorizontalOptions="End">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnAttend" />
</Image.GestureRecognizers>
<Image.Margin>
<OnIdiom x:TypeArguments="Thickness">
<OnIdiom.Phone>0, 0, 5, 0</OnIdiom.Phone>
<OnIdiom.Tablet>5, 5, 20, 5</OnIdiom.Tablet>
</OnIdiom>
</Image.Margin>
</Image>
<Image
Style="{StaticResource listviewButtonStyle}"
IsVisible="{Binding EnabledSigning, Source={x:Reference page}}"
Source="ic_action_no.png"
VerticalOptions="FillAndExpand"
HorizontalOptions="End">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnAbsent" />
</Image.GestureRecognizers>
<Image.Margin>
<OnIdiom x:TypeArguments="Thickness">
<OnIdiom.Phone>5, 0, 0, 0</OnIdiom.Phone>
<OnIdiom.Tablet>20, 5, 5, 5</OnIdiom.Tablet>
</OnIdiom>
</Image.Margin>
</Image>
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
Try setting a listview caching strategy to improve performance.
See here for more details
Be aware though that you may need to jump through some hoops to use RecycleElement with FFImageLoading. The issue is described here
Also, please post your data template so we can see if it can be simplified.
Use RecyclerView
https://blog.xamarin.com/recyclerview-highly-optimized-collections-for-android-apps/
OR
Use FFImageLoading
https://github.com/luberda-molinet/FFImageLoading
to optimize and for smoother scroll
I am new to Xamarin forms.I am designing an application in which I want to display a list of pickers in a list view.The vales in the picker should be dynamic.Below is the code I have written.I struck at writing a List of Picker items in a List.Please anyone help me.Sorry for my English.Thanks in advance.
<ListView x:Name="WindowsList" BackgroundColor="Transparent"
ItemsSource="{Binding KitchenWindowsList}"
HeightRequest="300" IsVisible="{Binding KitchenVisibility}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5" HorizontalOptions="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding KitchenWindowName}" TextColor="#ece6dd" FontAttributes="Bold">
<Label.FontSize>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="15" Android="15" WinPhone="15" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="20" Android="20" WinPhone="20" />
</OnIdiom.Tablet>
</OnIdiom>
</Label.FontSize>
</Label>
<Picker x:Name="CurtainTypePicker" ItemsSource="{Binding TypeList}" Title="Choose Curtain" Grid.Column="1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Picker.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="40"/>
</OnIdiom.Tablet>
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="45"/>
</OnIdiom.Phone>
</OnIdiom>
</Picker.HeightRequest>
</Picker>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I am working on a listview in which I have a label and Picker.I want to detect the selected item of the picker which is inside the list view.I am not able to access the x:Name of picker in Xaml.cs file.Below is my code.Any one please help me if i am going in a wrong direction.Thanks in Advance.
Here is my Xaml code:
<ListView x:Name="MasterRoomList" BackgroundColor="Transparent"
ItemsSource="{Binding MasterRoomWindowsList}"
IsVisible="{Binding RoomsVisibility}" ItemTapped="OnItemTapped" SeparatorVisibility="None">
<ListView.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="150" Android="150" WinPhone="150" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="300" Android="300" WinPhone="300" />
</OnIdiom.Tablet>
</OnIdiom>
</ListView.HeightRequest>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding RoomName}" TextColor="Black" FontFamily="Avenir Book" VerticalTextAlignment="Center">
<Label.FontSize>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="13" Android="13" WinPhone="13" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="20" Android="20" WinPhone="20" />
</OnIdiom.Tablet>
</OnIdiom>
</Label.FontSize>
</Label>
<Picker x:Name="CurtainPicker" BackgroundColor="Transparent" TextColor="Black" ItemsSource="{Binding CurtainsTypeList}" SelectedIndexChanged="CurtainPicker_OnSelectedIndexChanged" Title="Select Style" Grid.Column="1" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand">
<Picker.HeightRequest>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="40" Android="40"/>
</OnIdiom.Tablet>
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="30" Android="30"/>
</OnIdiom.Phone>
</OnIdiom>
</Picker.HeightRequest>
</Picker>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Here is my Xaml.cs Code:
private void CurtainPicker_OnSelectedIndexChanged(object sender, EventArgs e)
{
var selectedItem = (string) CurtainPicker.SelectedItem;
}
var picker = (Picker)sender;
var selectedItem = (string) picker.SelectedItem;