enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
982 stars 110 forks source link

Add ability to bind to attachments property #619

Open nickl-martin opened 1 month ago

nickl-martin commented 1 month ago

Unless I'm mistaken, there's currently no way to bind to the attachments property. This would be useful to declare styles for Uranium controls that use attachments.

Currently you have to add the attachment to every instance of the UI control like so:

<mtrl:PickerField
    Title="My Picker"
    ItemsSource="{Binding Items}">
    <mtrl:PickerField.Attachments>
        <Image
        Margin="0,0,4,0"
        Source="expand.png"/>
    </mtrl:PickerField.Attachmets>
</mtrl:PickerField>

It would be useful to instead be able to define a style like this:

<Style 
    x:Key="PickerWithAttachment"
    TargetType="mtrl:PickerField">
    <Setter Property="Attachments">
        <Image
            Margin="0,0,4,0"
            Source="expand.png"/>
    </Setter>
</Style>

But when I try this I get the following error:

Cannot resolve property "Attachments" on type "PickerField (property missing or missing accessors)".

enisn commented 1 month ago

It seems it's not possible right now, it's a simple IEnumerable<IView> and the same instance should be used always. It's not a settable field.

https://github.com/enisn/UraniumUI/blob/6c2d666149e7bddb4ed4e1bd3babb77dd11e3fd8/src/UraniumUI.Material/Controls/InputField.cs#L70