0
votes

I have a custom view with some bindable properties. There is something wrong, so when I try to open the page it won't open. I'm not getting an error or output. Using FreshMVVM to push the page model.

When I remove the BindableProperty BarcodeTypeProperty, the page opens.

public class BarcodeView : Image
{
    public static readonly BindableProperty BarcodeValueProperty = BindableProperty.Create(nameof(BarcodeValue), typeof(string), typeof(BarcodeView));
    public string BarcodeValue
    {
        get => (string)GetValue(BarcodeValueProperty);
        set => SetValue(BarcodeValueProperty, value);
    }

    public static readonly BindableProperty BarcodeTypeProperty = BindableProperty.Create(nameof(BarcodeType), typeof(BarcodeType), typeof(BarcodeView));
    public BarcodeType BarcodeType
    {
        get => (BarcodeType)GetValue(BarcodeTypeProperty);
        set => SetValue(BarcodeTypeProperty, value);
    }
}

The BarcodeType is an Enum:

public enum BarcodeType
{
    DataMatrix,
    Pdf417
}

Usage in Xaml:

<view:BarcodeView BarcodeType="{Binding BarcodeType}" BarcodeValue="abcd"/>
1

1 Answers

0
votes

Try to give BarcodeTypeProperty a default value as enum cannot be null.

public static readonly BindableProperty BarcodeTypeProperty = BindableProperty.Create("BarcodeType", typeof(BarcodeType), typeof(BarcodeView), BarcodeView.DataMatrix);