robinmanuelthiel / flexbutton

Flexible button control for Xamarin.Forms
MIT License
240 stars 34 forks source link

Icon Crashing on Xamarin.Forms 4.0.0 #80

Closed ghost closed 5 years ago

ghost commented 5 years ago

I tested every property of the FlexButton because my app was crashing in every page that had it, and when i commented out the icon property, i just started working again

linda-dge commented 5 years ago

I am having the same problem. The icon does not work.

uptondev commented 5 years ago

Just confirmed this is failing for me as well after upgrading to Xamarin.Forms v 4.0.0.497661

Here is how I was using it:

<flex:FlexButton Text="Next" HeightRequest="44" WidthRequest="130" CornerRadius="4" Margin="0,0,0,16" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" Icon="ic_forward" IconOrientation="Right" //<-- REMOVE THIS as workaround ForegroundColor="#ffffff" HighlightForegroundColor="#ffffff" BackgroundColor="{StaticResource PrimaryColorDark}" HighlightBackgroundColor="{StaticResource PrimaryColor}" x:Name="btnNext" />

The error that it throws looks like this:

System.NullReferenceException Object reference not set to an instance of an object at Flex.Android.Effects.ColorOverlayEffectAndroid.SetOverlay (Xamarin.Forms.Color color) [0x0002b] in :0 at Flex.Android.Effects.ColorOverlayEffectAndroid.OnAttached () [0x0004e] in :0 at Xamarin.Forms.Effect.SendAttached () [0x00009] in D:\a\1\s\Xamarin.Forms.Core\Effect.cs:54 at Xamarin.Forms.RoutingEffect.SendAttached () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\RoutingEffect.cs:29 :

Thanks for any assistance you can provide.

junaid-Apex commented 5 years ago

Having exactly same issue with FlexButton when update to XF4.0. Any solution to this problem?

uptondev commented 5 years ago

I ended up creating my own control which is borderline at best:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:effects="clr-namespace:Namespace.Helpers;assembly=Namespace"
    x:Class="Namespace.Controls.MIGButton">

    <!-- Button.Image property is screwed up in Xamarin so I stack a 
         transparent button on top of my image inside a grid so everything
         just auto-sizes to the available space -->

    <ContentPage.Resources>
        <ResourceDictionary>
            <Style TargetType="Button" BasedOn="{StaticResource ThemeButtonStyle}">
            </Style>
        </ResourceDictionary>        
    </ContentPage.Resources>

    <ContentView.Content>
        <Grid x:Name="grd" BackgroundColor="{StaticResource PrimaryColorDark}" HeightRequest="44" WidthRequest="130" effects:RoundCornersEffect.CornerRadius="6" Margin="0,12,0,24" HorizontalOptions="Center">
            <Image x:Name="img" Source="ic_forward"
                BackgroundColor="Transparent"
                HorizontalOptions="End"
                VerticalOptions="Center"
                IsOpaque="True"
                Margin="0,0,22,0"
            ></Image>
            <Label  x:Name="lbl" Text="Next" 
                TextColor="#FFFFFF" 
                HorizontalOptions="StartAndExpand" 
                VerticalOptions="Center" 
                Margin="22,0,0,0" 
                HorizontalTextAlignment="End" 
                BackgroundColor="Transparent"/>
            <Button x:Name="btn" HeightRequest="44" WidthRequest="130"
                HorizontalOptions="End"
                VerticalOptions="Start"
                BackgroundColor="Transparent"
                Clicked="OnButtonClicked">
            </Button>
        </Grid>
    </ContentView.Content>
</ContentView>

In the code behind I can move stuff around when the icon needs to be on the other side etc...kind of a hack until I can find something better (or some time)

robinmanuelthiel commented 5 years ago

Thanks for the feedback. Can you please confirm, that this is fixed with version 0.10.0?https://www.nuget.org/packages/Forms.Controls.FlexButton/0.10.0

uptondev commented 5 years ago

I've confirmed it is working for me. Sorry it took so long to respond...Thanks!