diff --git a/samples/ControlGallery/Views/PickerPlayground.razor b/samples/ControlGallery/Views/PickerPlayground.razor
index b3243583..c72af0c2 100644
--- a/samples/ControlGallery/Views/PickerPlayground.razor
+++ b/samples/ControlGallery/Views/PickerPlayground.razor
@@ -9,7 +9,7 @@
-
+
-
+
-
+
-
+
@@ -103,4 +103,9 @@
SelectedModelDefault = ModelsWithDefault.LastOrDefault();
SelectedIndex = -1;
}
+
+ public string ItemDisplay(PickerModel model)
+ {
+ return $"❤️{model.Name}❤️";
+ }
}
diff --git a/src/Microsoft.MobileBlazorBindings/Elements/Handlers/PickerHandler.cs b/src/Microsoft.MobileBlazorBindings/Elements/Handlers/PickerHandler.cs
index acd0b07a..88fb9ce4 100644
--- a/src/Microsoft.MobileBlazorBindings/Elements/Handlers/PickerHandler.cs
+++ b/src/Microsoft.MobileBlazorBindings/Elements/Handlers/PickerHandler.cs
@@ -10,7 +10,7 @@
namespace Microsoft.MobileBlazorBindings.Elements.Handlers
{
- public class PickerHandler : ViewHandler
+ public class PickerHandler : ViewHandler
{
public PickerHandler(NativeComponentRenderer renderer, MC.Picker pickerControl) : base(renderer, pickerControl)
{
@@ -68,7 +68,8 @@ public override void ApplyAttribute(ulong attributeEventHandlerId, string attrib
PickerControl.HorizontalTextAlignment = (TextAlignment)AttributeHelper.GetInt(attributeValue);
break;
case nameof(MC.Picker.ItemDisplayBinding):
- PickerControl.ItemDisplayBinding = new MC.Binding((string)attributeValue);
+ var func = (Func)attributeValue;
+ PickerControl.ItemDisplayBinding = new MC.Internals.TypedBinding((item) => (func(item), true), null, null);
break;
case nameof(MC.Picker.ItemsSource):
var items = AttributeHelper.DelegateToObject(attributeValue);
diff --git a/src/Microsoft.MobileBlazorBindings/Elements/Picker.cs b/src/Microsoft.MobileBlazorBindings/Elements/Picker.cs
index 05d34de6..7a01fb0c 100644
--- a/src/Microsoft.MobileBlazorBindings/Elements/Picker.cs
+++ b/src/Microsoft.MobileBlazorBindings/Elements/Picker.cs
@@ -6,6 +6,7 @@
using Microsoft.Maui.Graphics;
using Microsoft.MobileBlazorBindings.Core;
using Microsoft.MobileBlazorBindings.Elements.Handlers;
+using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MC = Microsoft.Maui.Controls;
@@ -21,7 +22,7 @@ public class Picker : View
[Parameter] public IList ItemsSource { get; set; }
#pragma warning restore CA2227 // Collection properties should be read only
[Parameter] public string Title { get; set; }
- [Parameter] public string ItemDisplayBinding { get; set; }
+ [Parameter] public Func ItemDisplayBinding { get; set; }
[Parameter] public TItem SelectedItem { get; set; }
[Parameter] public int SelectedIndex { get; set; } = -1;
[Parameter] public EventCallback SelectedItemChanged { get; set; }
@@ -67,7 +68,7 @@ public class Picker : View
static Picker()
{
- ElementHandlerRegistry.RegisterElementHandler>(renderer => new PickerHandler(renderer, new MC.Picker()));
+ ElementHandlerRegistry.RegisterElementHandler>(renderer => new PickerHandler(renderer, new MC.Picker()));
}
protected override void RenderAttributes(AttributesBuilder builder)