【问题标题】:Implementing IValueConverter in Xamarin on runtime在运行时在 Xamarin 中实现 IValueConverter
【发布时间】:2022-06-13 21:20:08
【问题描述】:

我有一个 IValueConverter 类,我希望将它的值除以我在 rntime 期间选择的数量!但是,不知道有没有可能!!

IvalueConverter

class salesUIbtnWidth : IValueConverter
{
    public double myValue { get; set; }
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (double)value / myValue;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

尝试实现类

 <Button Text="Click me" HorizontalOptions="Center" VerticalOptions="Center"
         CornerRadius="15" WidthRequest="{Binding Source={x:Reference 
         frame}, Path=Width,Converter={StaticResource salesUIbtnWidth}}">
 </Button>//how to bind also the MyValue

我只想知道如何在运行时从 xamarin 的 (IvalueConverter) 中设置 myValue

【问题讨论】:

标签: xamarin xamarin.forms xamarin.android xamarin.ios


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-18
  • 1970-01-01
相关资源
最近更新 更多