This is a migrated thread and some comments may be shown as answers.

Browse button to collectioneditor

3 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 13 Sep 2016, 06:23 AM

I have a CollectionEditor called Pictures which has key value pairs as items. The value is a path to an image file. My template for CollectionEditor looks like this:

<Style TargetType="telerik:CollectionEditor">
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=Bit}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

I would like to add a browse button to the 'content' field. Is that possible?

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 15 Sep 2016, 09:07 AM
Hello Joel,

As the CollectionEditor uses a RadPropertyGrid in its ControlTemplate to represent the different properties of the items within the source collection, you need to modify the ControlTemplate of the CollectionEditor and set an EditorTemplateSelector for the PropertyGrid it uses. Eventually, you can return a button for the specific PropertyDefinition as shown in the article.

Please check the attached sample where I have shown how to achieve the desired behavior.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Joel
Top achievements
Rank 1
answered on 15 Sep 2016, 10:12 AM

The Browse button doesn't seem to work in the example.

-Joel

0
Stefan Nenchev
Telerik team
answered on 15 Sep 2016, 01:01 PM
Hi Joel,

The example just shows how to add a button or any other element as an editor for a given PropertyDefinition. As you can see, no logic is triggered when clicking it as I just wanted to give you a broad idea of the path you need to take. Eventually, It is up to you to further modify it so that your exact requirement is achieved. 

Please check the AutoBindBehavior with EditorTemplateSelector demo from our SDK Samples Browser 
as it shows how you can bind a property of your business object to the selected file of an OpenFIleDialog.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Joel
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Joel
Top achievements
Rank 1
Share this question
or