Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

anyone got an example of a control with a boolean property with binding?

$
0
0

I'm able to add string properties to my control; but I can't get it to work with boolean ones.
i.e
`//in my custom control
public static readonly BindableProperty EnabledProperty = BindableProperty.Create ("EnabledFlag", typeof(bool), typeof(bool), true);

public bool EnabledFlag {
        get{ return (bool)GetValue (EnabledProperty); }
        set {
            SetValue (EnabledProperty, value);
            UpdateButtonImage ();
        }
    }

//in my xaml

<localControls:ExtendedButton
x:Name ="SpaceButton"
EnabledFlag="false"
WORKS

<localControls:ExtendedButton
x:Name ="SpaceButton"
EnabledFlag="true"
WORKS

<localControls:ExtendedButton
x:Name ="SpaceButton"
EnabledFlag="{Binding IsSpaceViewEnabled}"
//doens't work - exception : "cannot assign property EnabledFlag type mismatch between Xmarin.Forms.Binding and System.Boolean
....
`

my view model (which corresponds to the Binding above) has the IsSpaceViewEnabledProperty as such
` bool _isSpaceViewEnabled;

    public bool IsSpaceViewEnabled { get { return _isSpaceViewEnabled; } set { SetProperty (ref _isSpaceViewEnabled, value); } }

and the viewnodel extends ObservableObject
`


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>