Issue
I have a class of IValueConverter with a property named myValue which I want to divide the ivalueconverter by its property myValue! But, I want to know if it is possible to pass the myValue from xamarin page to ivalueconverter? If yes, how?
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();
}
}
Try Implementing the class
<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
All I want is to know how to set myValue in page and pass it to (IvalueConverter) from xamarin during runtime!!
Solution
According to your question this is what you need to do!
Following @Jessie Zhang example
<Button HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"
HeightRequest="{Binding Source={x:Reference frame}, Path=Height,
Converter={StaticResource doubleToInt}, ConverterParameter=enterYOURvaluHERE}"></Button>
Answered By - Atsenogua Sandra
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.