Skip to content

NullReferenceException when using global Style #75

@NickeManarin

Description

@NickeManarin

I'm getting a NullReferenceException when using a global Style.
The same does not happen when the Style has a key and it's applied to the Button itself.

This is the Style:

<Style TargetType="{x:Type l:FlexButton}">
    <Setter Property="FontSize" Value="16"/>
    <Setter Property="BackgroundColor" Value="{DynamicResource Color.Foreground}"/>
    <Setter Property="ForegroundColor" Value="{DynamicResource Color.Background.Odd}"/>
    <Setter Property="FontFamily" Value="{StaticResource Font.Heavy}"/>
    <Setter Property="CornerRadius" Value="10"/>
</Style>

This is the Button:

<l:FlexButton WidthRequest="25" HeightRequest="25" CornerRadius="38" Text="X" FontSize="10" Padding="0" VerticalOptions="Start" HorizontalOptions="End"/>

The Exception happens when executing this code:

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
private void InitializeComponent() 
{
    global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(PhotosView));
}

StackTrace:

   at Flex.Controls.FlexButton.SetButtonMode()
   at Flex.Controls.FlexButton.OnPropertyChanged(String propertyName)
   at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
   at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
   at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
   at Xamarin.Forms.Setter.Apply(BindableObject target, Boolean fromStyle)
   at Xamarin.Forms.Style.ApplyCore(BindableObject bindable, Style basedOn)
   at Xamarin.Forms.Style.Xamarin.Forms.IStyle.Apply(BindableObject bindable)
   at Xamarin.Forms.MergedStyle.SetStyle(IStyle implicitStyle, IList`1 classStyles, IStyle style)
   at Xamarin.Forms.MergedStyle.OnImplicitStyleChanged()
   at Xamarin.Forms.MergedStyle.<RegisterImplicitStyles>b__30_0(BindableObject bindable, Object oldvalue, Object newvalue)
   at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
   at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
   at Xamarin.Forms.Element.OnSetDynamicResource(BindableProperty property, String key)
   at Xamarin.Forms.BindableObject.SetDynamicResource(BindableProperty property, String key, Boolean fromStyle)
   at Xamarin.Forms.MergedStyle.RegisterImplicitStyles()
   at Xamarin.Forms.MergedStyle..ctor(Type targetType, BindableObject target)
   at Xamarin.Forms.NavigableElement..ctor()
   at Xamarin.Forms.VisualElement..ctor()
   at Xamarin.Forms.View..ctor()
   at Xamarin.Forms.Layout..ctor()
   at Flex.Controls.FlexButton..ctor()
   at MyApp.View.RegistrationSteps.PhotosView.InitializeComponent()
   at MyApp.View.RegistrationSteps.PhotosView..ctor()
   at MyApp.ViewModel.SignUpViewModel.Load_Executed()
   at Xamarin.Forms.Command.<>c__DisplayClass4_0.<.ctor>b__0(Object o)
   at Xamarin.Forms.Command.Execute(Object parameter)
   at MyApp.View.SignUp.OnAppearing()
   at Xamarin.Forms.Page.SendAppearing()
   at Xamarin.Forms.Page.SendAppearing()
   at Xamarin.Forms.Platform.UWP.NavigationPageRenderer.OnLoaded(Object sender, RoutedEventArgs args)

Please complete the following information:

  • Which version of the FlexButton do you use? 0.9.1
  • Which version of Xamarin.Forms do you use? 3.6.0.293080
  • Which OS are you talking about? Android and UWP

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions