DrawerLayout: How to make this Custom Layout - xamarin

I want to make these in a DrawerLayout but unable to find the right approach.
WANT THESE LAYOUTS
and
I have tried and been thinking about this. Should I use
1 - List
Problem: How to add separator and group things.
2 - List + Grid
3 - TableView
I am posting code below. I am not experienced and don't think its the right approach. Give me some directions Please.
CODE
<ListView.Header>
<Grid BackgroundColor="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Image Source="bg.jpg" Aspect="AspectFill" />
<StackLayout Padding="11,110,0,20" >
<Label Text="AppName" TextColor="White" FontSize="Medium" Style="{DynamicResource SubtitleStyle}"/>
</StackLayout>
</Grid>
</Grid>
</ListView.Header>
<ListView.ItemsSource>
<x:Array Type="{x:Type local:MasterPageItem}">
<local:MasterPageItem Title="All Tasks" IconSource="ic_date_range_black_48dp.png" TargetType="{x:Type local:ContactsPage}" Color="Black" />
<local:MasterPageItem Title="Today" IconSource="ic_date_range_black_48dp.png" TargetType="{x:Type local:TodoListPage}" Color="Black"/>
<local:MasterPageItem Title="Completed" IconSource="ic_check_black_48dp.png" TargetType="{x:Type local:ReminderPage}" Color="Green"/>
<local:MasterPageItem Title="InComplete" IconSource="ic_close_black_48dp.png" TargetType="{x:Type local:ReminderPage}" Color="Red"/>
<local:MasterPageItem Title="My List" IconSource="ic_date_range_black_48dp.png" TargetType="{x:Type local:ReminderPage}" Color="Black"/>
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Image Source="{Binding IconSource}" VerticalOptions="Center"/>
<Label Grid.Column="1" Text="{Binding Title}" TextColor="{Binding Color}" FontSize="Medium" VerticalOptions="Center"/>
<Label Grid.Column="2" Text="5" TextColor="Black" FontSize="Medium" VerticalOptions="Center"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<BoxView VerticalOptions="Center" HorizontalOptions="FillAndExpand" HeightRequest="1" Color="#5b5d68"></BoxView>
<Grid Padding="5,10" BackgroundColor="#e8e8e8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<Image Grid.Column="0" Grid.Row="0" Source="ic_date_range_black_48dp.png" VerticalOptions="Center"/>
<Label Grid.Column="1" Grid.Row="0" Text="Create List" TextColor="Gray" FontSize="Medium" VerticalOptions="Center"/>
<Image Grid.Column="0" Grid.Row="1" Source="ic_date_range_black_48dp.png" VerticalOptions="Center"/>
<Label Grid.Column="1" Grid.Row="1" Text="Settings" TextColor="Gray" FontSize="Medium" VerticalOptions="Center"/>
</Grid>
</StackLayout>
RESULT
Thanks

I think you need to set the ItemsSource of listview in code.
For example:
public ListView ListView;
public MasterPage1()
{
InitializeComponent();
ListView = ItemListview;
List<List<MasterPageItem>> masterPageItemGroup = new List<List<MasterPageItem>>(){
new List<MasterPageItem>(){
new MasterPageItem() { Title = "All Tasks", IconSource = "ic_date_range_black_48dp.png", Color = "Black" }
},
new List<MasterPageItem>(){
new MasterPageItem() { Title="Today", IconSource="ic_date_range_black_48dp.png", Color="Black" },
new MasterPageItem() { Title = "Completed", IconSource = "ic_check_black_48dp.png", Color = "Green" },
new MasterPageItem() { Title = "InComplete", IconSource = "ic_close_black_48dp.png", Color = "Red" },
},
new List<MasterPageItem>(){
new MasterPageItem() { Title="My List", IconSource="ic_date_range_black_48dp.png" , Color="Black" }
},
};
ListView.ItemsSource = masterPageItemGroup;
}
Then set IsGroupingEnabled value to true in xaml. And if you want to hide group header, you also need to set HasUnevenRows to true and use the ListView.GroupHeaderTemplate. In the GroupHeaderTemplate create a ViewCell and set Height to 0.
Here is the xaml:
<ListView x:Name="ItemListview" IsGroupingEnabled="true" HasUnevenRows="True">
<ListView.Header>
<Grid BackgroundColor="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Image Source="bg.jpg" Aspect="AspectFill" />
<StackLayout Padding="11,110,0,20" >
<Label Text="AppName" TextColor="White" FontSize="Medium" Style="{DynamicResource SubtitleStyle}"/>
</StackLayout>
</Grid>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Image Source="{Binding IconSource}" VerticalOptions="Center"/>
<Label Grid.Column="1" Text="{Binding Title}" TextColor="{Binding Color}" FontSize="Medium" VerticalOptions="Center"/>
<Label Grid.Column="2" Text="5" TextColor="Black" FontSize="Medium" VerticalOptions="Center"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell Height="0">
<Grid/>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
</ListView>
The result is:
Update:
How can I remove/hide line above All Tasks?. This shouldn't be there.
It seems that it could not be removed. But the is a workaround. If you remove the <RowDefinition Height="*" /> in your ListView.Header, the line will be hidden by bg.jpg.
The result:

Related

Programmatically modification of CarouselView

I have a CarouselView inside a ScrollView. To control the height I calculate it and modify it programmatically. It almost works, but the problem however is that it only works when the height is increased not when the height is decreased.
CarouselView
<CarouselView x:Name="cv" HeightRequest="8" ItemsSource="{Binding Challenge.ChallengeParts}" VerticalOptions="Center" ItemTemplate="{StaticResource ChallengePartTemplate}" Position="{Binding PageCarouselPosition}" Grid.Row="0" Grid.Column="1"></CarouselView>```
DataTemplate
<DataTemplate x:Key="ChallengePartTemplate">
<StackLayout BackgroundColor="LimeGreen" VerticalOptions="Center">
<Grid x:Name="rulesGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<StackLayout x:Name="toggleShowRules" Grid.Column="0" Grid.Row="0">
<Label x:Name="showRulesText" Text="Vis regler fra video" FontAttributes="Bold" Grid.Column="0" Grid.Row="0" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference thisPage}, Path=BindingContext.ToggleShowRulesTappedCommand}" />
</StackLayout.GestureRecognizers>
</StackLayout>
<Label Text="{Binding Source={x:Reference thisPage}, Path=BindingContext.ShowRules,Converter={StaticResource CaretConverter}}" FontFamily="{StaticResource FontAwesomeSolid}" Grid.Column="1" Grid.Row="0" HorizontalTextAlignment="End" />
</Grid>
<StackLayout x:Name="showRulesStack" IsVisible="{Binding Source={x:Reference thisPage}, Path=BindingContext.ShowRules}">
<Grid Margin="20, 0, 0, 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--Antal spillere-->
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="0">
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
</StackLayout>
<StackLayout x:Name="numPlayersText" Spacing="0" Grid.Column="1" Grid.Row="0">
<Label Text="Antal spillere:" FontAttributes="Bold" FontSize="Micro" />
<Label Text="{Binding NumPlayers}" FontSize="Micro" />
</StackLayout>
<!--Nødvendigt udstyr-->
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="1">
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
</StackLayout>
<StackLayout Spacing="0" Grid.Column="1" Grid.Row="1">
<Label Text="Nødvendigt udstyr:" FontAttributes="Bold" FontSize="Micro" />
<StackLayout BindableLayout.ItemsSource="{Binding NeededAccesories}" Spacing="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding .}" FontSize="Micro" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
<!--Regler-->
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="2">
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
</StackLayout>
<StackLayout Grid.Column="1" Grid.Row="2">
<Label Text="Regler:" FontAttributes="Bold" FontSize="Micro" />
<StackLayout BindableLayout.ItemsSource="{Binding Rules}" Spacing="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding .}" FontSize="Micro" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</Grid>
</StackLayout>
</StackLayout>
</DataTemplate>
Code behind
var cvVisibleViews = cv.VisibleViews;
if(cvVisibleViews.Count > 0)
{
var rulesStack = cvVisibleViews[0].FindByName<StackLayout>("showRulesStack");
var toggleShowRules = cvVisibleViews[0].FindByName<StackLayout>("toggleShowRules");
var showRulesText = cvVisibleViews[0].FindByName<Label>("showRulesText");
double height = 0;
height = height + toggleShowRules.Height;
height = height + showRulesText.Height;
if (rulesStack.IsVisible && rulesStack.Height > -1)
{
height = height + rulesStack.Height;
}
cv.HeightRequest = height;
}
It seems like the new height of the CarouselView is measured from the center of it. Like the content is placed outside above the CarouselView
Any idea to realign the content inside the resized CarouselView?
Thanks a lot!

Infinite load for CollectionView does not work and RemainingItemsThresholdReached never get fired?

I'm trying to load CollectionView incrementally but RemainingItemsThresholdReached never get fired, I tried to use RemainingItemsThresholdReachedCommand also but no luck.
Here is my code, hope someone can figure out what's going wrong.
<CollectionView x:Name="collectionView" ItemsSource="{Binding Users}" VerticalScrollBarVisibility="Always"
RemainingItemsThreshold="3"
RemainingItemsThresholdReached="LoadMoreAsync" >
<CollectionView.ItemTemplate>
<DataTemplate >
<Border Stroke="White" Background="Black" StrokeThickness="2"
Padding="8" Margin="10">
<Border.StrokeShape>
<RoundRectangle CornerRadius="10,10,10,10"/>
</Border.StrokeShape>
<StackLayout >
<StackLayout Orientation="Horizontal" Spacing="20" Padding="10">
<Image Source="download.png" HeightRequest="40" WidthRequest="40" />
<Label Text="{Binding UserName}" FontSize="14" FontAttributes="Bold" />
</StackLayout>
<BoxView Color="Gray" HeightRequest="2" HorizontalOptions="Fill" />
<Label Padding="7" Text="{Binding Description}"/>
<BoxView Color="Gray" HeightRequest="1" HorizontalOptions="Fill" />
<StackLayout Orientation="Horizontal" Spacing="20" Padding="10">
<Grid HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<ImageButton Grid.Row="0" Grid.Column="0" Source="user.png" HeightRequest="20" WidthRequest="20" />
<ImageButton Grid.Row="0" Grid.Column="1" Source="like.png" HeightRequest="20" WidthRequest="20" />
<ImageButton Grid.Row="0" Grid.Column="2" Source="chat.png" HeightRequest="20" WidthRequest="20" />
</Grid>
</StackLayout>
</StackLayout>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
the backend side:
public void LoadMoreAsync(object sender, EventArgs e)
{
if (IsBusy)
return;
IsBusy = true;
GetUsers(pageNumber, 6);
pageNumber++;
IsBusy = false;
}

Changing BackgroundColor of Button within Xamarin CollectionView changes the BackgroundColor of every 8th button down. why?

I have a Xamarin CollectionView That uses a Button (Button x:Name="PNameButton") to Change the Background color of the button.
When the Button is clicked the background color changes... However - So does every 8th Button in the CollectionView. Its as if the CollectionView renders new data every 8 or so items, and that new first button gets the changed color property. How do I fix this? Code Follows:
<CollectionView x:Name="PairingsCollectionView" SelectionMode="Multiple" Margin="20,5,20,5" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Margin="0" Padding="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="35" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Column="0" Grid.Row="0" Margin="0" Color="#333130"/>
<Button x:Name="PNameButton" Margin="0" Padding="0,0,0,0" Grid.Column="0" BackgroundColor="{Binding UseColor}" Text="{Binding PDisplayName}" FontSize="Small" TextColor="Black"
HorizontalOptions="Start" VerticalOptions="Center" Clicked="Button_Clicked" />
<BoxView Grid.Column="1" Grid.Row="0" Color="#333130" Margin="0"></BoxView>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="1" TextColor="White" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center" >
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding PDays, StringFormat='{0}Dy'}"/>
<Span Text=" "/>
<Span Text="{Binding PDay}"/>
</FormattedString>
</Label.FormattedText>
</Label>
<BoxView Grid.Row="0" Grid.Column="2" Margin="0" Color="#333130"></BoxView>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="2" Text="{Binding PCredit, StringFormat='{0}'}" TextColor="#F57BFA" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="0" Grid.Column="3" Color="#333130" Margin="0"></BoxView>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="3" Text="{Binding PFlightTime, StringFormat='{0}'}" TextColor="White" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="0" Grid.Column="4" Color="#333130" Margin="0"/>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="4" Text="{Binding PRegionType, StringFormat='{0}'}" TextColor="White" FontSize="Small" HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="0" Grid.Column="5" Color="#333130" Margin="0"/>
<CheckBox x:Name="IsSelectedCheckbox" Grid.Row="0" Grid.Column="5" IsChecked="{Binding PIsSelected}" VerticalOptions="Center"/>
<BoxView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Color="LightGray"></BoxView>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Text="{Binding PDateModified}" TextColor="Black" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" Color="LightGray" ></BoxView>
<Label Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" Text="{Binding PLayovers}"
TextColor="Coral" FontAttributes="Bold" FontSize="17" HorizontalOptions="Start" VerticalOptions="Center" Margin="5,0,0,0" />
<WebView Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="6" BackgroundColor="#333130"
MinimumHeightRequest="150" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
HeightRequest="{Binding PWebViewHeight}" >
<WebView.Source>
<HtmlWebViewSource Html="{Binding PAllText}"/>
</WebView.Source>
</WebView>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
And in the Code Behind:
private void Button_Clicked(object sender, EventArgs e)
{
try
{
string ChkVal = "";
bool compareBool = false;
bool currentState = false;
Color buttonColer;
string ColorHexVal;
int i = 0;
var thisButton = sender as Button;
buttonColer = thisButton.BackgroundColor;
ColorHexVal = buttonColer.ToHex();
if (buttonColer != Color.FromHex("#F7F75A"))
{
currentState = true;
}
else
{
currentState = false;
}
var PairingItem = ((Button)sender).Parent.BindingContext as Pairings;
compareBool = App.DatabaseNA.GetIsSelected(PairingItem.PID);
if (!compareBool == true)
{
thisButton.BackgroundColor = Color.FromHex("#46AE3C");
}
else
{
thisButton.BackgroundColor = Color.FromHex("#F7F75A");
}
}
catch (Exception ex)
{
DisplayAlert("Alert", ex.InnerException.ToString(), "OK"); //await
}
}
Again - Thank You!!!
The code works great and sets the Background color of the button... The problem is - It sets the Background Color of every Button about 8 items down.
Thanks

Xamarin Forms Android Views Inflate Exception

In my forms project, when navigating to the shell page from content page , i am getting Unhandled Exception: Android.Views.InflateException: <Timeout exceeded getting exception details>
. I am using visualstudio 2017 community version.Important thing is there is no error when using visualstudio 2019 community edition.This happened after merging with a sub branch.I have tried deleting bin,obj folders, downgrading xamarin version etc.Nothing found useful.I am stuck at this point.Please help...
AppShell.xaml
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FlyoutBehavior="Flyout"
FlyoutIsPresented="True"
xmlns:local="clr-namespace:WeCareMobility.Views"
Title="WeCareMobility" FlyoutBackgroundColor="DarkBlue"
x:Class="WeCareMobility.AppShell">
<!--Styles and Resources-->
<Shell.Resources>
<ResourceDictionary>
<Color x:Key="NavigationPrimary">#002060</Color>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource NavigationPrimary}" />
<Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
<Setter Property="Shell.TabBarForegroundColor" Value="White"/>
<Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
<Setter Property="Shell.TabBarTitleColor" Value="White"/>
</Style>
<Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" />
</ResourceDictionary>
</Shell.Resources>
<ShellItem >
<ShellSection>
<ShellContent>
<local:HomePage />
</ShellContent>
</ShellSection>
</ShellItem>
<Shell.FlyoutHeaderTemplate>
<DataTemplate>
<Grid Padding="10" BackgroundColor="White" HorizontalOptions="CenterAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image Source="steering_logo.png"/>
<Label Grid.Column="1" Text="Copiloto" FontSize="Large" FontAttributes="Bold" TextColor="Black" VerticalOptions="Center"/>
</Grid>
</DataTemplate>
</Shell.FlyoutHeaderTemplate>
<Shell.ItemTemplate>
<DataTemplate>
<Grid Padding="10" BackgroundColor="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Text="Change language" Clicked="Lan_Btn_Clicked" Style="{StaticResource FlyoutButtonStyle}"/>
<Button Grid.Row="1" Text="Trip History" Clicked="LblTripHis_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
<Button Grid.Row="2" Text="Select Vehicle" Clicked="SelectVehicleTapped" Style="{StaticResource FlyoutButtonStyle}"/>
<Button Grid.Row="3" Text="Ask a service" Clicked="Service_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
<Button Grid.Row="4" Text="Bluetooth Connection" Clicked="Connection_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
<Button Grid.Row="5" Text="Change Password" Clicked="ResetPasswordTapped" Style="{StaticResource FlyoutButtonStyle}"/>
<Button Grid.Row="6" Text="About Us" Clicked="AboutUs_Tapped" Style="{StaticResource FlyoutButtonStyle}"/>
</Grid>
</DataTemplate>
</Shell.ItemTemplate>
</Shell>
AppShell.xaml.cs
namespace WeCareMobility
{
public partial class AppShell : Xamarin.Forms.Shell
{
public AppShell()
{
InitializeComponent();
}
}
HomePage.xaml
<ScrollView>
<Label VerticalOptions="StartAndExpand" HorizontalOptions="CenterAndExpand" Margin="0,30,0,0" FontSize="Medium" FontAttributes="Bold">
<Label.FormattedText>
<FormattedString>
<Span Text="{i18n:Translate Speed}" />
<Span Text="{Binding CurrentSpeed , StringFormat=' : {0:F1} km/h '}" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label Text="{Binding VehicleName}" TextColor="Black" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</Label.GestureRecognizers>
</Label>
<Frame Grid.Row="1" BackgroundColor="White" CornerRadius="10" HasShadow="True" HorizontalOptions="FillAndExpand">
<Grid Margin="5,5,5,0" ColumnSpacing="10" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.ColumnSpan="2" Text="{i18n:Translate Scoring}" FontAttributes="Bold"/>
<Label Grid.Column="2" Text="Month" FontSize="Small" TextColor="SkyBlue" HorizontalOptions="End"/>
<Image Grid.Column="3" Source="triangle.png" HeightRequest="15" WidthRequest="15" HorizontalOptions="Start"/>
<StackLayout Grid.Row="1" Grid.ColumnSpan="4" HorizontalOptions="FillAndExpand" Margin="0,0,0,10">
<!--<chart:SfChart>
<chart:SfChart.Title>
<chart:ChartTitle Text="Project Cost Breakdown"/>
</chart:SfChart.Title>
<chart:SfChart.BindingContext>
<viewmodel:DoughnutSeriesViewModel />
</chart:SfChart.BindingContext>
<chart:SfChart.Legend>
<chart:ChartLegend IconHeight="0" IconWidth="0" DockPosition="Bottom" />
</chart:SfChart.Legend>
<chart:SfChart.Series>
<chart:DoughnutSeries ItemsSource="{Binding DoughnutSeriesData}" XBindingPath="Name" YBindingPath="Value" TrackBorderColor="{Binding TrackColor}" LegendIcon="None" IsVisibleOnLegend="False" DoughnutCoefficient="0.8">
<chart:DoughnutSeries.DataMarker>
<chart:ChartDataMarker ShowLabel="False">
<chart:ChartDataMarker.LabelStyle>
<chart:DataMarkerLabelStyle LabelFormat="##'M'"/>
</chart:ChartDataMarker.LabelStyle>
</chart:ChartDataMarker>
</chart:DoughnutSeries.DataMarker>
<chart:DoughnutSeries.ColorModel>
<chart:ChartColorModel Palette="Natural" />
</chart:DoughnutSeries.ColorModel>
<chart:DoughnutSeries.CenterView>
<Label Text="50" TextColor="Black" FontAttributes="Bold" FontSize="30" FontFamily="Helvetica" HorizontalTextAlignment="Center"/>
</chart:DoughnutSeries.CenterView>
</chart:DoughnutSeries>
</chart:SfChart.Series>
</chart:SfChart>-->
</StackLayout>
<Label Grid.Row="2" Text="Best Grade" FontAttributes="Bold"/>
<Label Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Text="Worst Grade" FontAttributes="Bold"/>
<Label Grid.Row="3" Text="Cornering"/>
<Label Grid.Row="3" Grid.Column="1" Text="Phone Distraction" Grid.ColumnSpan="2"/>
</Grid>
</Frame>
<Frame Grid.Row="2" BackgroundColor="White" CornerRadius="10" HasShadow="True" HorizontalOptions="FillAndExpand">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<!--<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>-->
</Grid.ColumnDefinitions>
<Label Grid.ColumnSpan="9" Text="Current Trip" FontAttributes="Bold"/>
<Image Grid.Row="1" Grid.ColumnSpan="9" Source="wecare_map.png" HorizontalOptions="FillAndExpand"/>
<Label Grid.Row="2" Grid.ColumnSpan="9" Text="Holborn, London UK"/>
<Label Grid.Row="3" Text="Distance" FontSize="12"/>
<Label Grid.Row="3" Grid.Column="1" Text="120" FontSize="12"/>
<Label Grid.Row="3" Grid.Column="2" Text="km" FontAttributes="Bold" FontSize="12"/>
<!--<Label Grid.Row="3" Grid.Column="3" Text="m" TextColor="Transparent" BackgroundColor="Transparent"/>-->
<Label Grid.Row="3" Grid.Column="3" Text="1h02" FontAttributes="Bold" HorizontalOptions="End" FontSize="12"/>
<Label Grid.Row="3" Grid.Column="4" Text="Duration" HorizontalOptions="Start" FontSize="12"/>
<!--<Label Grid.Row="3" Grid.Column="6" Text="m" TextColor="Transparent" BackgroundColor="Transparent" HorizontalOptions="Start"/>-->
<Label Grid.Row="3" Grid.Column="5" Text="3" FontAttributes="Bold" HorizontalOptions="End" FontSize="12"/>
<Image Grid.Row="3" Grid.Column="6" Source="error.png" HeightRequest="15" WidthRequest="15" HorizontalOptions="Start"/>
</Grid>
</Frame>
<Frame Grid.Row="3" BackgroundColor="DarkBlue" CornerRadius="10" HasShadow="True" HorizontalOptions="FillAndExpand">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Text="Summary" TextColor="White" FontAttributes="Bold"/>
<Label Grid.Column="1" Text="Month" FontSize="Small" TextColor="SkyBlue" HorizontalOptions="End"/>
<Image Grid.Column="2" Source="triangle.png" HeightRequest="15" WidthRequest="15" HorizontalOptions="Start"/>
<!--<flv:FlowListView Grid.Row="2" Grid.ColumnSpan="3" FlowColumnCount="2" SeparatorVisibility="None" HasUnevenRows="True"
FlowItemsSource="{Binding TempList}">
<flv:FlowListView.FlowColumnTemplate>
<DataTemplate>
<Frame BackgroundColor="Transparent">
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.RowSpan="2" Source="{Binding ImgSource}" HeightRequest="20"/>
<Label Grid.Column="1" Text="{Binding Header}" FontSize="12"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Detail}" FontSize="8"/>
</Grid>
</Frame>
</DataTemplate>
</flv:FlowListView.FlowColumnTemplate>
</flv:FlowListView>-->
<!--<flv:FlowListView x:Name="listview" HasUnevenRows="true" FlowColumnCount="2" FlowItemsSource="{Binding TempList}"
BackgroundColor="#ECD2FC">
<flv:FlowListView.FlowColumnTemplate>
<DataTemplate>
<Frame HasShadow="True" OutlineColor="Red" Margin="2">
<StackLayout>
<Label Text="Test" FontSize="20" FontAttributes="Bold"/>
</StackLayout>
</Frame>
</DataTemplate>
</flv:FlowListView.FlowColumnTemplate>
</flv:FlowListView>-->
<!--<ListView Grid.Row="2" Grid.ColumnSpan="2" ItemsSource="{Binding TempList}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Image Grid.RowSpan="2" Source="{Binding ImgSource}"/>
<Label Grid.Column="1" Text="{Binding Header}"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Detail}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>-->
<FlexLayout Grid.Row="2" Grid.ColumnSpan="2" BindableLayout.ItemsSource="{Binding TempList}"
Wrap="Wrap" Direction="Row" FlowDirection="LeftToRight" JustifyContent="Start" AlignItems="Start">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Frame BackgroundColor="Transparent">
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.RowSpan="2" Source="{Binding ImgSource}" HeightRequest="22"/>
<Label Grid.Column="1" Text="{Binding Header}" FontSize="13" TextColor="White"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Detail}" FontSize="9" TextColor="White"/>
</Grid>
</Frame>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</Grid>
</Frame>
</Grid>
</ScrollView>
<Frame BackgroundColor="Green" HorizontalOptions="FillAndExpand" VerticalOptions="EndAndExpand">
<Label Text="Page under Development" HorizontalOptions="CenterAndExpand" FontSize="Medium" TextColor="White"/>
</Frame>
HomePage ViewModel:
public HomePageViewModel(Page page) : base(page)
{
_BeaconList = new List<Features.Home.Beacon>();
TranslateCommand = new Command(translate);
tripstart = false;
if (TripCollection == null)
{
TripCollection = new List<Trip>();
}
}
public override void Init()
{
IsInitialized = true;
if(BeaconPageViewModel.ConnectedVehicle != null)
{
VehicleName = BeaconPageViewModel.ConnectedVehicle;
DetectSpeed();
}
else
{
VehicleName = "No Vehicle";
}
}
private async void DetectSpeed()
{
var sunday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
try
{
var hasPermission = await Utils.CheckPermissions(Permission.Location);
if (!hasPermission)
return;
if (tracking)
{
CrossGeolocator.Current.PositionChanged -= CrossGeolocator_Current_PositionChanged;
CrossGeolocator.Current.PositionError -= CrossGeolocator_Current_PositionError;
}
else
{
CrossGeolocator.Current.PositionChanged += CrossGeolocator_Current_PositionChanged;
CrossGeolocator.Current.PositionError += CrossGeolocator_Current_PositionError;
}
if (CrossGeolocator.Current.IsListening)
{
await CrossGeolocator.Current.StopListeningAsync();
tracking = false;
}
else
{
if (await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 1,
false, new ListenerSettings
{
AllowBackgroundUpdates = true,
DeferLocationUpdates = true,
DeferralDistanceMeters = 1,
DeferralTime = TimeSpan.FromSeconds(1),
ListenForSignificantChanges = true,
PauseLocationUpdatesAutomatically = true
}))
{
tracking = true;
}
}
}
catch (Exception ex)
{
await App.Current.MainPage.DisplayAlert("Uh oh", "Something went wrong, but don't worry we captured for analysis! Thanks.", "OK");
}
}
void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e)
{
ticks++;
tripPoints = new TripPoints();
var position = e.Position;
var speedms = position.Speed;
_kmh = speedms * 3.6;
if (_kmh > 3.00)
{
count++ ;
if (count > 11)
{
if (!tripstart)
{
tripstart = true;
DependencyService.Get<IToast>().LongAlert("Trip started");
DateTime dateAndTime = DateTime.Now;
trip = new Trip();
trip.StartDate = DateTime.Now;
trip.StartTime = dateAndTime.ToString("hh:mm tt");
trip.TripPointList = new List<TripPoints>();
}
CurrentSpeed = _kmh.ToString("N2");
OnPropertyChanged("CurrentSpeed");
App.Current.Properties.Remove("Zerotime");
}
}
else if (_kmh < 1.00)
{
CurrentSpeed = _kmh.ToString("N2");
OnPropertyChanged("CurrentSpeed");
var lasttime = DateTime.Now;
if (App.Current.Properties.ContainsKey("Zerotime"))
{
var zerotime = (DateTime)App.Current.Properties["Zerotime"];
var SecondDifference = (lasttime - zerotime).TotalSeconds;
if (SecondDifference > 119)
{
if (tripstart == true)
{
DependencyService.Get<IToast>().LongAlert("Trip stopped");
tripstart = false;
count = 0;
DateTime dateAndTime = DateTime.Now;
// trip.EndDate = dateAndTime.ToShortDateString();
trip.EndDate = DateTime.Now;
trip.EndTime = dateAndTime.ToString("hh:mm tt");
trip.Distance = TotalDistance;
TripCollection.Add(trip);
}
}
}
else
{
App.Current.Properties["Zerotime"] = DateTime.Now;
}
}
}
Exception Details:
09-14 21:31:00.177 I/MonoDroid( 3357): UNHANDLED EXCEPTION:
09-14 21:31:00.202 I/MonoDroid( 3357): Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class xamarin.forms.platform.android.appcompat.FormsViewPager ---> Android.Views.InflateException: Binary XML file line #1: Error inflating class xamarin.forms.platform.android.appcompat.FormsViewPager ---> Java.Lang.ClassNotFoundException: Didn't find class "xamarin.forms.platform.android.appcompat.FormsViewPager" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/lib/arm64, /data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk!/lib/arm64-v8a, /system/lib64]]
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class xamarin.forms.platform.android.appcompat.FormsViewPager
09-14 21:31:00.371 F/.WeCareMobilit( 3357): java_vm_ext.cc:542] at android.view.View
09-14 21:31:00.372 F/.WeCareMobilit( 3357): java_vm_ext.cc:542] Caused by: java.lang.ClassNotFoundException: Didn't find class "xamarin.forms.platform.android.appcompat.FormsViewPager" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/lib/arm64, /data/app/com.WeCare.WeCareMobility-eCFGWA6K-RTib0RvLztsCQ==/base.apk!/lib/arm64-v8a, /system/lib64]]
09-14 21:31:00.372 F/.WeCareMobilit( 3357): java_vm_ext.cc:542] (Throwable with no stack trace)

How to add badge count in Navigation bar with TabbedPage In Xamarin forms?

I want to add navigation bar in cart icon with badge count.
I have added cart icon in navigation bar using toolbar item. and also created badge count circle view using plugin. if i am giving margin to set that badge icon to toolbar item it is hide behind tabbed page.
It is not displaying on cart icon.
Please help me out this.
As per above image i want to set badge count with tabbed page.
Below is my XAML Code.
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lang="clr-namespace:Conekto"
xmlns:controls="clr-namespace:Conekto.Controls;"
x:Class="ProjectName.Pages.SalePage">
<TabbedPage.Children>
<ContentPage Title="{lang:Translate PRODUCTLIST}">
<Grid Margin="10,10,10,0" BackgroundColor="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Text="charge 15,123" Style="{StaticResource primaryButton}" />
<SearchBar x:Name="txtSearch" Grid.Row="1" Grid.Column="0" TextChanged="MySearchBarOnTextChanged" Placeholder="{lang:Translate Search}" SearchCommand="{Binding SearchCommand, Mode=TwoWay}" CancelButtonColor="Blue" Text="{Binding SearchText, Mode=TwoWay}" Style="{StaticResource labelgreycolour}" WidthRequest="50" HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" />
<StackLayout Grid.Row="2" Grid.Column="0" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand">
<ListView x:Name="listView" ItemsSource="{Binding ProductList}" HasUnevenRows="True" IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}" ItemAppearing="listView_ItemAppearing" ItemSelected="listView_ItemSelected" SelectedItem="{Binding listView_ItemSelected, Mode=TwoWay}" BackgroundColor="White" HorizontalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="0,5,0,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="40*" />
</Grid.ColumnDefinitions>
<Image Source="add" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Aspect="AspectFit" HeightRequest="30" WidthRequest="30" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.AddProductCommand, Source={x:Reference listView}}" CommandParameter="{Binding .}" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Grid.Row="0" Grid.Column="1" VerticalOptions="CenterAndExpand" VerticalTextAlignment="End" Text="{Binding ProductName,Mode=TwoWay}" Style="{StaticResource entrylogin}" />
<Label Grid.Row="1" Grid.Column="1" VerticalOptions="CenterAndExpand" VerticalTextAlignment="End" Text="{Binding Cost,Mode=TwoWay,StringFormat='XOF {0}'}" Style="{StaticResource listViewsublabel}" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</Grid>
<controls:FloatingActionButton Margin="0,0,20,20" Grid.Row="0" x:Name="FABCart" HorizontalOptions="End" VerticalOptions="End" WidthRequest="60" HeightRequest="60" Image="cart" ButtonColor="#09999A" Clicked="FabCart_Clicked" />
<controls:BadgeView Margin="0,0,32,52" Grid.Row="0" Text="{Binding TotalCartItem, Mode=TwoWay}" BadgeColor="White" HorizontalOptions="End" VerticalOptions="End" />
</Grid>
</ContentPage>
<ContentPage Title="{lang:Translate KEYPAD}">
<ContentPage.BackgroundColor>
<OnPlatform x:TypeArguments="Color">
<OnPlatform.Platforms>
<On Platform="iOS" Value="Black" />
<On Platform="Android" Value="#eee" />
</OnPlatform.Platforms>
</OnPlatform>
</ContentPage.BackgroundColor>
<Grid x:Name="controlGrid" Margin="0,0,0,0" Padding="0,0,0,0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.ColumnSpacing>
<OnPlatform x:TypeArguments="x:Double">
<OnPlatform.Platforms>
<On Platform="iOS" Value="1" />
<On Platform="Android" Value="0" />
</OnPlatform.Platforms>
</OnPlatform>
</Grid.ColumnSpacing>
<Grid.RowSpacing>
<OnPlatform x:TypeArguments="x:Double">
<OnPlatform.Platforms>
<On Platform="iOS" Value="1" />
<On Platform="Android" Value="0" />
</OnPlatform.Platforms>
</OnPlatform>
</Grid.RowSpacing>
<Grid.RowDefinitions>
<RowDefinition Height="74" />
<RowDefinition Height="80" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Text="charge 15,123" Margin="12,12,12,12" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Style="{StaticResource primaryButton}" />
<Label Text="Add note" FontSize="10" Grid.Column="0" Grid.Row="1" HorizontalTextAlignment="Center" VerticalTextAlignment="End" TextColor="Black" />
<Label x:Name="lblVal" Margin="0,0,16,0" Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" VerticalTextAlignment="Center" TextColor="Black" FontSize="30" Grid.ColumnSpan="2" VerticalOptions="End" />
<Button Clicked="Button_Clicked" Text ="7" Grid.Row="2" Grid.Column="0" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "8" Grid.Row="2" Grid.Column="1" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "9" Grid.Row="2" Grid.Column="2" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "4" Grid.Row="3" Grid.Column="0" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "5" Grid.Row="3" Grid.Column="1" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "6" Grid.Row="3" Grid.Column="2" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "1" Grid.Row="4" Grid.Column="0" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "2" Grid.Row="4" Grid.Column="1" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "3" Grid.Row="4" Grid.Column="2" Style="{StaticResource plainButton}" />
<Button Clicked="ButtonClear_Clicked" Text = "C" Grid.Row="5" Grid.Column="0" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "0" Grid.Row="5" Grid.Column="1" Style="{StaticResource plainButton}" />
<Button Clicked="Button_Clicked" Text = "+" Grid.Row="5" Grid.Column="2" Style="{StaticResource plainButton}" />
</Grid>
</ContentPage>
<ContentPage Title="{lang:Translate SCAN}">
</ContentPage>
</TabbedPage.Children>
And in .cs Page code i am adding cart icon in toolbar item.
ToolbarItems.Add(new ToolbarItem("Add Product", "floating", async () =>
{
//var page = new ContentPage();
//var result = await page.DisplayAlert("Title", "Message", "Accept", "Cancel");
await Navigation.PushAsync(new CreateProductPage() { Title = Helper.GetResxNameByValue("CreateProduct") });
//Debug.WriteLine("success: {0}", result);
}));
As per design i have added cart button as floating button. Please do not consider that.
To add badge on toolbar item you can hide the default tool bar by using NavigationPage.SetHasNavigationBar(this, false); then you can create your own tool bar with button having badge counter and hamburger to show and hide side menu.
On page in which hamburger button is clicked:
private void Button_Clicked(object sender, System.EventArgs e)
{
MessagingCenter.Send(this, "presnt");
}
On MasterDetail page:
MessagingCenter.Subscribe<YourPage>(this, "presnt", (sender) =>
{
IsPresented = true;
});
Also, Before making IsPresented=true, check for sliding menu is not all-ready presented.
you can check https://github.com/LeslieCorrea/Xamarin-Forms-Shopping-Cart this link for more information. But by using this method in android may make the nav bar appear below tabs, so you may need to create tabs using buttons.
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal">
<Label FontAttributes="Bold" TextColor="Black" FontSize="Medium" Text="Female Category" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"></Label>
<AbsoluteLayout Margin="0,0,5,0" HorizontalOptions="EndAndExpand">
<Frame BackgroundColor="White" BorderColor="Black" CornerRadius="50" WidthRequest="40"
Padding="0"
Margin="0,10,0,10">
<ImageButton Source="add_to_basket.png" BackgroundColor="Transparent" Clicked="ImageButton_Clicked" Padding="5"/>
</Frame>
<Frame BackgroundColor="Red" HeightRequest="30" BorderColor="Black" WidthRequest="20" CornerRadius="50" Padding="0,0,0,-10" Margin="25,5,0,0">
<Label HorizontalOptions="CenterAndExpand" Text="53" TextColor="White" />
</Frame>
</AbsoluteLayout>
</StackLayout>
</NavigationPage.TitleView>

Resources