Hello,
The Value Convertor will get value from the property value of Path.
For instance:
<Binding Source="{RelativeSource Self}"
Path="WidthRequest">
If you set WidthRequest
to Path, you will find the value of converter is 200.
Therefore, you need to set a new property into Image
to bind DeviceHasScanner
as the following code:
public class MyImage : Image
{
public static readonly BindableProperty DeviceHasScannerProperty =
BindableProperty.Create("DeviceHasScanner", typeof(bool), typeof(MyImage), null);
public bool DeviceHasScanner
{
get { return (bool)GetValue(DeviceHasScannerProperty); }
set { SetValue(DeviceHasScannerProperty, value); }
}
}
In XAML:
<converters:MyImage x:Name="img" HorizontalOptions="Center" WidthRequest="200" DeviceHasScanner="{Binding DeviceHasScanner}">
...
<Binding Source="{RelativeSource Self}"
Path="DeviceHasScanner">
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.