Forum Xamarin Xamarin.Forms

Xamarin Forms XAML - Boolean attribute set from XAML

Emixam23Emixam23 USMember ✭✭✭


I don't understand something about how to set object attribute for xaml about boolean..

I have a MainPage.xaml like this where I set ProportionalSize to true:

    <converter:BooleanConverter x:Key="Boolean"/>

  <!-- Background during loading of start -->
    <local:CustomImage Source="{extension:ImageResource HomeBG.png}"
                     ProportionalWidth="100" ProportionalHeight="100" ProportionalSize="{True, Converter={StaticResource Boolean}}"
                     AbsoluteLayout.LayoutBounds="0.5, 0.5, 1, 1"

I use a customImage for some reason, this is the class

public class CustomImage : Image
    private bool _ProportionalSize;
    public bool ProportionalSize
        get { return this._ProportionalSize; }
            this._ProportionalSize = value;

Because neither true nor True works, I made a BooleanConverter

public class BooleanConverter : IValueConverter
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        return (bool)value;

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        return (bool)value;

However, it still doesn't work...

Additional information: Position 19:75. MarkupExtension not found for true
ProportionalSize="{True, Converter={StaticResource Boolean}}"

Does I'm doing something wrong?

Best Answer


  • does just setting it to true not work?


  • Emixam23Emixam23 USMember ✭✭✭

    It throws an exception..

    String was not recognized as a valid Boolean.

  • Emixam23Emixam23 USMember ✭✭✭

    OMG I'm totaly stupid....

    ProportionalWidth="100" ProportionalHeight="100" are boolean value

    I have to set ImageSize="100, 100" ................................

    I'll close the question, so stpid I can be sometime ! :/

    Thank for help

Sign In or Register to comment.