xabre / xamarin-forms-tab-badge

Xamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
MIT License
307 stars 75 forks source link

Badge not showing #71

Closed stesvis closed 5 years ago

stesvis commented 5 years ago

Hello, I don't understand why the badge is not showing even with this simple example like this:

<?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:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
            prism:ViewModelLocator.AutowireViewModel="True"
            x:Class="VeloGuideApp.Views.HomeTabbedPage"
            Title="VeloGuide"
            xmlns:plugin="clr-namespace:Plugin.Badge.Abstractions;assembly=Plugin.Badge.Abstractions"
            SelectedTabIndex="{Binding SelectedTab}">

    <TabbedPage.Children>
        <ContentPage Title="Tab1" 
                 Icon="icontab1.png"
                 plugin:TabBadge.BadgeText="New" plugin:TabBadge.BadgeColor="Red">
            <StackLayout></StackLayout>
        </ContentPage>
    </TabbedPage.Children>

</TabbedPage>

Turns out to this: Screenshot_20190620_163426_com veloguide mobile prod

What could I be missing?

I did add this to the AssemblyInfo.cs too: [assembly: ExportRenderer(typeof(CustomTabbedPageRenderer), typeof(BadgedTabbedPageRenderer))]

Where CustomTabbedPageRenderer is my custom tabbed page renderer.

Thanks for any help.

stesvis commented 5 years ago

UPDATE: the badge shows if I change it to this: [assembly: ExportRenderer(typeof(TabbedPage), typeof(BadgedTabbedPageRenderer))] But of course I lose my custom tabbed page customizations... @xabre any idea? Thx!

xabre commented 5 years ago

@stesvis You have to inherit your own custom renderer from the BadgedTabbedPageRenderer and then register your custom renderer.

public class CustomTabbedPageRenderer : BadgedTabbedPageRenderer

[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedPageRenderer))]