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

FilePathPIcker FilePath text does not update when bound property changes

2 Answers 313 Views
FilePathPicker
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Joe asked on 04 Mar 2021, 09:40 PM

I have a FilePathPicker with the FilePath property set to a two-way binding to a view-model property.  Whenever (in code-behind) I  set the corresponding bound property (and then Raise a PropertyChanged notification for it), the FilePath in the text box does not update, no matter what the UpdateSourceTrigger.  I cannot understand why.

I went and wrote a test application and reproduced the same effect.  Isn't the FilePath property supposed to work as a two-way binding?

Here is the XAML binding.

<tk:RadFilePathPicker FilePath="{Binding ReportHeaderImagePath, Mode=TwoWay}" IconVisibility="Collapsed"/>

 

 

And here is the bound property in the ViewModel

 

private string _reportHeaderImagePath;
 
public string ReportHeaderImagePath
{
    get => Settings.ReportHeaderImagePath;
    set
    {
        _reportHeaderImagePath = value;
        RaisePropertyChanged(nameof(ReportHeaderImagePath));
    }
}


When my code sets this ReportHeaderImagePath property to null or string.Empty, I can see the value being set in the debugger and I can see the PropertyChanged event being raised.   But still the editor in the RadFilePathPicker does not change.  The previous path stays there.   I have to either manually edit it or click the little "X" button inside it.

I have tried setting the Binding's UpdateSourceTrigger value all possible choices Default, LostFocus, PropertyChanged and even Explicit.  Nothing works.  

What am I missing?

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 09 Mar 2021, 08:26 AM

Hello Joe,

Please note the difference between the Text and FilePath properties of the RadFilePathPicker control. Text can be set and can hold a value, representing any string, but the FilePath property will change if the Text represents a string which is a valid file path in your file system. In your case , if you type "C:\" , FilePath will probably change, then if you continue typing 'W-in-d-o-w-s', the FilePath will not change until you type the string "C:\Windows" which probably is a valid path in your system. If you need to display in the control any string value from your ViewModel, simply bind the Text property instead of FilePath, but note the primary usage of the control is to help you choose a valid file path.

I hope this helps you move forward.

Regards,
Petar Mladenov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 09 Mar 2021, 05:21 PM
Than you, I completely missed that distinction.
Tags
FilePathPicker
Asked by
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Petar Mladenov
Telerik team
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or