I have a custom View with a custom BindableProperty:
public string Valore {
get { return (string)GetValue(ValoreProperty); }
set { SetValue(ValoreProperty, value); }
}
public static readonly BindableProperty ValoreProperty =
BindableProperty.Create(
propertyName: nameof(Valore),
returnType: typeof(string),
declaringType: typeof(VolosTimePickerView),
defaultBindingMode: BindingMode.TwoWay,
propertyChanged: ValorePropertyChanged,
propertyChanging: ValorePropertyChanging
);
In my XAML, since the value of Valore
is a nullable Int
, I must use a converter like this:
<view:VolosTimePickerView Grid.Row="0" Grid.Column="1"
Valore="{Binding OrariSelezionati.ViaggioInizioMattina, Converter={StaticResource NullableConverter}}" />
How can I do the same thing, without using Converter={StaticResource NullableConverter
in XAML side, but in code behind directly on the property?
Thank you!
Your
Valore
is astring
. Try to convert it intoNullable<int> Valore
. See what happens.And try to bind the value of the Valore inside your
ViewModel
also. So you would get