{"record":{"id":"ab8ceae4c2f5991b","repo":"unoplatform/uno","slug":"value-must-either-be-null-or-of-type-bool-got-va-ab8cea","errorCode":null,"errorMessage":"Value must either be null or of type bool. Got {value} ({value.GetType().FullName})","messagePattern":"Value must either be null or of type bool\\. Got (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Converters/FromNullableBoolToVisibilityConverter.cs","lineNumber":34,"sourceCode":"\t\t}\n\n\t\tpublic VisibilityIfTrue VisibilityIfTrue { get; set; }\n\n\t\tpublic object Convert(object value, Type targetType, object parameter, string language)\n\t\t{\n\t\t\tif (parameter != null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"This converter does not use any parameters. You should remove \\\"{parameter}\\\" passed as parameter.\");\n\t\t\t}\n\n\t\t\tbool inverse = this.VisibilityIfTrue == VisibilityIfTrue.Collapsed;\n\n\t\t\tVisibility visibilityOnTrue = (!inverse) ? Visibility.Visible : Visibility.Collapsed;\n\t\t\tVisibility visibilityOnFalse = (!inverse) ? Visibility.Collapsed : Visibility.Visible;\n\n\t\t\tif (value != null && !(value is bool))\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"Value must either be null or of type bool. Got {value} ({value.GetType().FullName})\");\n\t\t\t}\n\n\t\t\tvar valueToConvert = value != null && System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);\n\n\t\t\treturn valueToConvert ? visibilityOnTrue : visibilityOnFalse;\n\t\t}\n\n\t\tpublic object ConvertBack(object value, Type targetType, object parameter, string language)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\t}\n\n\tpublic enum VisibilityIfTrue\n\t{\n\t\tVisible,\n\t\tCollapsed\n\t}","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Converters/FromNullableBoolToVisibilityConverter.cs#L16-L52","documentation":"FromNullableBoolToVisibilityConverter.Convert throws when value is non-null and not a bool, after computing the visibility mapping. Only null or bool are accepted; any other type is a binding mismatch.","triggerScenarios":"Binding a non-bool source (int, Visibility, enum, string) to this converter.","commonSituations":"Wrong binding path; source type changed; chaining a converter that emits a non-bool type.","solutions":["Bind to a bool / bool? source.","Add an intermediate converter if the source is non-bool.","Inspect value.GetType().FullName in the message."],"exampleFix":"<!-- before -->\n{Binding State, Converter={StaticResource Vis}}\n<!-- after -->\n{Binding IsEnabled, Converter={StaticResource Vis}}","handlingStrategy":"type-guard","validationCode":"if (value is not null and not bool) throw new ArgumentException(\"expected bool?\");","typeGuard":"static bool IsNullableBool(object value) => value is null or bool;","tryCatchPattern":null,"preventionTips":["Bind bool / bool? sources only.","Inspect value.GetType().FullName from the message."],"tags":["xaml","binding","converter","type-mismatch","visibility","unit-tests","samples"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}