UraniumUI icon indicating copy to clipboard operation
UraniumUI copied to clipboard

Add ability to bind to attachments property

Open nickl-martin opened this issue 11 months ago • 1 comments

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)".

nickl-martin avatar Mar 15 '24 19:03 nickl-martin

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

enisn avatar Mar 20 '24 19:03 enisn