Unwanted exception thrown at the converter

I don't have idea about this exception. Please guide me about this exception.
<Grid Margin="0,20,0,0" IsVisible="{Binding FrontPageVisibility}"> <Image HeightRequest="320" Source="FrontB.png" WidthRequest="320" /> <StackLayout Margin="0,130,70,0" IsVisible="{Binding PageLocation, Converter={StaticResource FrontLeftButtonVisibilityConverter}}"> <ImageButton Source="purple_Circle.png" Style="{StaticResource ImageButtonStyle}" /> </StackLayout> <StackLayout Margin="70,130,0,0" IsVisible="{Binding PageLocation, Converter={StaticResource FrontRightButtonVisibilityConveter}}"> <ImageButton BackgroundColor="Transparent" Source="purple_Circle.png" Style="{StaticResource LocationPageButton}" /> </StackLayout> </Grid>

Converter code
` public class FrontLeftButtonVisibilityConverter :IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var pageTitle = false;
if (value is int)
if ((int) value == 1)
pageTitle = true;

        return pageTitle;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return null;
    }
}`

Exception is thrown at FrontLeftButtonVisibilityConverter and also at FrontRightButtonVisibilityConveter

Tagged:

Answers

  • SmartManSmartMan INMember ✭✭✭

    what you are getting in catch exception.Please add try catch and see

  • Suriya_KalidossSuriya_Kalidoss Member ✭✭✭

    Sorry, this issue is not in converter it is in xaml side issue. So I close this thread

  • Suriya_KalidossSuriya_Kalidoss Member ✭✭✭

    HI i got this exception
    Severity Code Description Project File Line Suppression State
    Error Position 106:54. Cannot assign property "Converter": Property does not exist, or is not assignable, or mismatching type between value and property

  • JarvanJarvan Member, Xamarin Team Xamurai

    Cannot assign property "Converter": Property does not exist, or is not assignable ... between value and property

    Something wrong with the binding code in xaml. When should we use Converter? For example, If you need to make visible a control only if the property has an opposite value. Just like Triggers, changes to the appearance of controls are based on property changes. You didn't specify the control and condition for Converter. The code should be like below, StackLaout's visibility depends on the ** Property_a ** of **contorl_a **..

    <Grid Margin="0,20,0,0" IsVisible="{Binding FrontPageVisibility}">
        <Image HeightRequest="320" Source="FrontB.png" WidthRequest="320" />
        <StackLayout Margin="0,130,70,0" IsVisible="{Binding Source={x:Reference contorl_a} , Path=Property_a , Converter={StaticResource FrontRightButtonVisibilityConveter}}">
            <ImageButton Source="purple_Circle.png" Style="{StaticResource ImageButtonStyle}" />
        </StackLayout>
        <StackLayout Margin="70,130,0,0" IsVisible="{Binding Source={x:Reference control_b} , Path=Property_b, Converter={StaticResource FrontRightButtonVisibilityConveter}}">
            <ImageButton BackgroundColor="Transparent" Source="purple_Circle.png" Style="{StaticResource LocationPageButton}" />
        </StackLayout>
    </Grid>
    

    Check the Tutorial:
    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/converters
    https://xamgirl.com/understanding-converters-in-xamarin-forms/

  • NMackayNMackay GBInsider, University mod
    edited October 21

    @Suriya_Kalidoss said:
    Sorry, this issue is not in converter it is in xaml side issue. So I close this thread

    @Suriya_Kalidoss
    If this thread closed? it ended up in the moderation queue! Let me know and I can close the thread if need be

  • Suriya_KalidossSuriya_Kalidoss Member ✭✭✭

    closed

This discussion has been closed.