0

カスタム 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
        );

私の XAML では、 の値がValorenullableIntであるため、次のようなコンバーターを使用する必要があります。

<view:VolosTimePickerView Grid.Row="0" Grid.Column="1" 
     Valore="{Binding OrariSelezionati.ViaggioInizioMattina, Converter={StaticResource NullableConverter}}" />

Converter={StaticResource NullableConverterXAML 側で使用せずに、プロパティの背後にあるコードで同じことを行うにはどうすればよいですか?

ありがとうございました!

4

1 に答える 1

0

あなたValorestringです。に変換してみてくださいNullable<int> Valore。何が起こるか見てください。

また、Valore の値をあなたの中にバインドしてみてくださいViewModel。だからあなたは得るでしょう

Nullable<int> _Valore;
public Nullable<int> Valore {get; set;}
于 2017-12-28T14:08:04.510 に答える