Browse button to collectioneditor

4 posts, 0 answers
  1. Joel
    Joel avatar
    3 posts
    Member since:
    Jun 2016

    Posted 13 Sep Link to this post

    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?

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 15 Sep Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joel
    Joel avatar
    3 posts
    Member since:
    Jun 2016

    Posted 15 Sep in reply to Stefan Nenchev Link to this post

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

    -Joel

  5. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    277 posts

    Posted 15 Sep Link to this post

    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.
Back to Top