Open BioTurboNick opened 2 hours ago
I have a Picker that is populated by an array of values. They are mapped to a localized string through a ValueConverter.
Picker
ValueConverter
Since updating to MAUI 9, the picker is now full of blank entries in release mode.
XAML:
<ContentView.Resources> <ResourceDictionary> <vc:IntToPowerConverter x:Key="intToPower" /> </ResourceDictionary> </ContentView.Resources> <Picker Grid.Column="2" FontSize="16" VerticalTextAlignment="End" ItemDisplayBinding="{Binding Converter={StaticResource intToPower}}"> <Picker.ItemsSource> <x:Array Type="{x:Type x:Int32}"> <x:Int32>0</x:Int32> <x:Int32>1</x:Int32> <x:Int32>2</x:Int32> <x:Int32>3</x:Int32> <x:Int32>4</x:Int32> <x:Int32>5</x:Int32> <x:Int32>6</x:Int32> <x:Int32>7</x:Int32> <x:Int32>8</x:Int32> <x:Int32>9</x:Int32> </x:Array> </Picker.ItemsSource> </Picker>
C#:
static readonly char[] superscriptCharacters = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹', '⁻']; static readonly char[] characters = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-']; static readonly Dictionary<char, char> superscriptDictionary = new(superscriptCharacters.Length); const char times = '×'; public static string GetSuperscript(int exponentValue, CultureInfo culture) { string formatedValue = exponentValue.ToString("D", culture); string formattedSuperscripts = string.Empty; for (int i = 0; i < formatedValue.Length; i++) formattedSuperscripts += superscriptDictionary[formatedValue[i]]; return formattedSuperscripts; } public static string ToPowerOfTen(int value, CultureInfo culture) { string formattedValue = string.Empty; if (value == 0) return formattedValue; formattedValue += times + 10.ToString(culture); if (value == 1) return formattedValue; formattedValue += GetSuperscript(value, culture); return formattedValue; } public class IntToPowerConverter : IValueConverter { public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (targetType != typeof(string)) return new object(); return value switch { int intValue => FormatHelpers.ToPowerOfTen(intValue, culture), _ => string.Empty }; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); }
No response
9.0.10 SR1
Yes, this used to work in .NET MAUI
8.0.92 SR9.2
Android
Android 14
@simonrozsival This is using ItemDisplayBinding and I know we touched that in .NET 9...
ItemDisplayBinding
FWIW I have confirmed that if I remove ItemDisplayBinding= the items show up.
ItemDisplayBinding=
Description
I have a
Picker
that is populated by an array of values. They are mapped to a localized string through aValueConverter
.Since updating to MAUI 9, the picker is now full of blank entries in release mode.
Steps to Reproduce
XAML:
C#:
Link to public reproduction project repository
No response
Version with bug
9.0.10 SR1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.92 SR9.2
Affected platforms
Android
Affected platform versions
Android 14
Did you find any workaround?
No response
Relevant log output