Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Update Picker.ItemDisplayBinding to be Func instead of string #460

Open
Dreamescaper opened this issue Jun 16, 2022 · 0 comments · May be fixed by #461
Open

Update Picker.ItemDisplayBinding to be Func instead of string #460

Dreamescaper opened this issue Jun 16, 2022 · 0 comments · May be fixed by #461

Comments

@Dreamescaper
Copy link
Contributor

Dreamescaper commented Jun 16, 2022

Currently in our Picker implementation ItemDisplayBinding property has a string type, which represents property name which should be displayed, so if I have the following item type:

class Item
{
	public string Id {get;set;}
	public string Name {get;set;}
}

I can use ItemDisplayBinding="Name" so Picker would use this property for items.

But
a) It has no compile time validation
b) It's not flexible. What if I want to use multiple properties for display item or use custom function?

It should be Func instead (ItemDisplayBinding="i => i.Name").
We can use Maui's TypedBinding to convert Func to Binding to be able to assign it to Maui's control.

One thing I'm not sure about is naming. Does it make sense to rename it to smth like ItemDisplaySelector? Since it has no relation to Maui's Bindings? Or leave it as is?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant