title | page_title | description | slug | tags | position |
---|---|---|---|---|---|
Getting Started |
Getting Started |
This article will walk you through the creation of a sample application that contains a RadFilePathPicker control. |
radfilepathpicker-getting-started |
getting,started,radfilepathpicker |
2 |
This tutorial will walk you through the creation of a sample application that contains a RadFilePathPicker control.
To use RadFilePathPicker when working with NuGet packages, install the Telerik.Windows.Controls.FileDialogs.for.Wpf.Xaml
package. The [package name may vary]({%slug nuget-available-packages%}) slightly based on the Telerik dlls set - [Xaml or NoXaml]({%slug xaml-vs-noxaml%})
Read more about NuGet installation in the [Installing UI for WPF from NuGet Package]({%slug nuget-installation%}) article.
tip With the 2025 Q1 release, the Telerik UI for WPF has a new licensing mechanism. You can learn more about it [here]({%slug installing-license-key%}).
If you are not using NuGet packages, you can add a reference to the following assemblies:
- Telerik.Licensing.Runtime
- Telerik.Windows.Controls
- Telerik.Windows.Controls.Input
- Telerik.Windows.Controls.Navigation
- Telerik.Windows.Controls.GridView
- Telerik.Windows.Controls.FileDialogs
- Telerik.Windows.Data
You can find the required assemblies for each control from the suite in the [Controls Dependencies]({%slug installation-installing-controls-dependencies-wpf%}) help article.
Example 1 demonstrates how you can define a RadFilePathPicker in xaml.
{{region xaml-radfilepathpicker-getting-started-0}} <telerik:RadFilePathPicker x:Name="filePathPicker" /> {{endregion}}
Even at this point, you are ready to start using the control. The following few sections will demonstrate some of the features of the RadFilePathPicker.
By default the RadFilePathPicker is read-only, which means that you cannot input text in the RadWatermarkTextBox inside it. In order to change this, you can set the IsReadOnly property to False as demonstrated in Example 2.
{{region xaml-radfilepathpicker-getting-started-1}} <telerik:RadFilePathPicker IsReadOnly="False" /> {{endregion}}
The RadFilePathPicker control exposes two properties that come in handy for working with input: Text and FilePath. The Text property is updated constantly when the user is typing. The FilePath property is only updated when a valid file path is entered or when one is selected through a file dialog.
There are two properties that allow for modifying the appearance of the button on the right side of the control, which opens the dialog. The ShowDialogButtonContent expects a glyph as a value, since the default ShowDialogButtonTemplate contains a [RadGlyph]({%slug common-styling-appearance-radglyph%}). Example 3 demonstrates how to change the default glyph shown in the button.
{{region xaml-radfilepathpicker-getting-started-2}} <telerik:RadFilePathPicker ShowDialogButtonContent="" /> {{endregion}}
If you don't want to show a RadGlyph in the show dialog button, you can set the ShowDialogButtonTemplate property to a custom DataTemplate. Note, that whatever is set to the ShowDialogButtonContent will be the DataContext inside the ShowDialogButtonTemplate.
{{region xaml-radfilepathpicker-getting-started-3}}
<StackPanel>
<StackPanel.Resources>
<DataTemplate x:Key="ShowDialogButtonTemplate">
<TextBlock Text="{Binding}" />
</DataTemplate>
</StackPanel.Resources>
<telerik:RadFilePathPicker ShowDialogButtonContent="Show" ShowDialogButtonTemplate="{StaticResource ShowDialogButtonTemplate}" />
</StackPanel>
{{endregion}}
There are two properties that allow for modifying the appearance of the clear button, which is shown when some text is entered. The ClearButtonContent expects a glyph as a value, since the default ClearButtonTemplate contains a [RadGlyph]({%slug common-styling-appearance-radglyph%}). Example 5 demonstrates how to change the default glyph shown in the button.
{{region xaml-radfilepathpicker-getting-started-4}} <telerik:RadFilePathPicker IsReadOnly="False" ClearButtonContent="" /> {{endregion}}
To avoid showing a RadGlyph in the clear button, you can set the ClearButtonTemplate property to a custom DataTemplate. Note, that whatever is set to the ClearButtonContent will be the DataContext inside the ClearButtonTemplate.
{{region xaml-radfilepathpicker-getting-started-5}}
<StackPanel>
<StackPanel.Resources>
<DataTemplate x:Key="ClearButtonTemplate">
<TextBlock Text="{Binding}" />
</DataTemplate>
</StackPanel.Resources>
<telerik:RadFilePathPicker IsReadOnly="False" ClearButtonContent="Clear" ClearButtonTemplate="{StaticResource ClearButtonTemplate}"/>
</StackPanel>
{{endregion}}
Since the 2020.1.316 internal build version, the RadFilePathPicker automatically sets its FilePath when a file is dropped over it. If multiple files are dropped, the first one will be used. In order to disable this functionality, you can set the AllowDrop property of the control to False.
The controls from our suite support different themes. You can see how to apply a theme different than the default one in the [Setting a Theme]({%slug styling-apperance-implicit-styles-overview%}) help article.
important Changing the theme using implicit styles will affect all controls that have styles defined in the merged resource dictionaries. This is applicable only for the controls in the scope in which the resources are merged.
To change the theme, you can follow the steps below:
-
Choose between the themes and add reference to the corresponding theme assembly (ex: Telerik.Windows.Themes.Windows8.dll). You can see the different themes applied in the Theming examples from our WPF Controls Examples application.
-
Merge the ResourceDictionaries with the namespace required for the controls that you are using from the theme assembly. For the RadFilePathPicker, you will need to merge the following resources:
- Telerik.Windows.Controls
- Telerik.Windows.Controls.Input
- Telerik.Windows.Controls.Navigation
- Telerik.Windows.Controls.GridView
- Telerik.Windows.Controls.FileDialogs
Example 7 demonstrates how to merge the ResourceDictionaries so that they are applied globally for the entire application.
{{region radfilepicker-getting-started_9}} <Application.Resources> <ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries> </Application.Resources> {{endregion}}
Alternatively, you can use the theme of the control via the {% if site.site_name == 'WPF' %}StyleManager{% else %}StyleManager{% endif %}.
Figure 7 shows a RadFilePathPicker with the Windows8 theme applied.
{% if site.site_name == 'WPF' %}
- Telerik UI for WPF FilePathPicker Component
- [Getting Started with Telerik UI for WPF Components]({%slug getting-started-first-steps%})
- [Telerik UI for WPF Installation]({%slug installation-installing-which-file-do-i-need%})
- [Telerik UI for WPF and WinForms Integration]({%slug winforms-integration%})
- [Telerik UI for WPF Visual Studio Templates]({%slug visual-studio-templates%})
- [Setting a Theme with Telerik UI for WPF]({%slug styling-apperance-implicit-styles-overview%})
- Telerik UI for WPF Virtual Classroom (Training Courses for Registered Users)
- Telerik UI for WPF License Agreement {% endif %}
- [Commands]({%slug radfilepathpicker-commands%})
- [Dialog Types]({%slug radfilepathpicker-dialog-types%})
- [WatermarkTextbox Properties]({%slug radfilepathpicker-watermarktextbox-properties%})
- [IconTemplateSelector]({%slug radfilepathpicker-icontemplateselector%})