【发布时间】:2022-06-10 22:01:07
【问题描述】:
请问题可能很有趣,一点也不有趣或令人困惑!但我想要的简单目标是在运行时更改 xamarin.forms 中绑定上下文的值!!
IvalueConverter
class LoginFrameHeight : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (double)value / 1.9;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
资源字典
<ResourceDictionary>
<local:LoginFrameHeight x:Key="frameHeight"/>
</ResourceDictionary>
设置框架高度
<Frame CornerRadius="15"
HeightRequest="{Binding Source={x:Reference frame},
Path=Height,Converter={StaticResource frameHeight}}" Padding="0"></Frame>
代码运行良好!我的问题是我有大约 三 (3) 帧 可以使用相同的流程应用不同的 HeightRequested!是否可以在 IvalueConverter 期间更改 (1.9) 运行时,以便我可以使用相同的类 LoginFrameHeight 而不是为框架创建不同的类?
【问题讨论】:
-
比例因子从何而来?它是绑定对象的属性,还是每个帧的硬编码值,还是其他什么?
标签: xamarin xamarin.forms xamarin.android xamarin.ios