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

FileName Property

6 Answers 140 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 26 Apr 2013, 11:31 AM

This seems like it would be a common issue but I have not been able to find a reference in either the documentation or forums. I have a class that I want to edit using the RadPropertyGrid and one of the public properties is a string that contains a file path. I want to use the OpenFileDialog (or equivalent) to edit this property. Any help would be appreciated...

Thanks
Dave Goughnour

6 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 01 May 2013, 03:23 PM
Hello,

 Please excuse us for the delayed answer. Basically, RadPropertyGrid does not have such default editor, but you can easily customize it. Here is an article that illustrates how to assign your own editors to the fields. I guess that you need some button which displays OpenFIleDialog when gets clicked. Please, do not hesitate to ask for additional assistance in case it is needed.

Regards,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 03 Jun 2013, 03:25 PM
I've tried many property grids in my days, and most of them have this functionality. Why not implement it for Q2?
0
David
Top achievements
Rank 1
answered on 03 Jun 2013, 03:39 PM
I should have replied a while ago. Turns out this is really easy using a template (I used a template selector since I had a number of other properties that I wanted custom editors for as well. The XAML is:
<Grid.Resources>
    <local:PropertyGridTemplateSelector x:Key="dataTemplateSelector">
        <local:PropertyGridTemplateSelector.FilenamePropertyTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Text="{Binding FilePath}" Grid.Column="0"/>
                    <Button Content="..." Width="25" Height="25" Grid.Column="1" Click="SelectFileClick"/>
                </Grid>
            </DataTemplate>
        </local:PropertyGridTemplateSelector.FilenamePropertyTemplate>
        <!-- More templates here -->
    </local:PropertyGridTemplateSelector>
</Grid.Resources>

Obviously the SelectFileClick handler displays the OpenFileDialog...
0
Kristoffer
Top achievements
Rank 1
answered on 03 Jun 2013, 03:41 PM
Ah, thanks a lot!!
0
Kristoffer
Top achievements
Rank 1
answered on 04 Jun 2013, 04:37 PM
Do I have to specify a data template for all data types? Ideally, I would inherit Telerik's implementation and add support for certain Filename properties.
0
Ivan Ivanov
Telerik team
answered on 06 Jun 2013, 03:05 PM
Hello Guys,

@David, Thank you for posting this sample code.
@Kristoffer, our current policy towards RadPropertyGrid is to make it easily customizable, so that clients can adapt it for their custom needs. We have default editors for the most common types and we implement such for the most popular feature request, but we have never had considerable demand for filename editor. We will consider it for the future releases, in case it gains popularity.

Regards,
Ivan Ivanov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
David
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Kristoffer
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or