I have a FileInfo
type DependencyProperty and in the PropertyChangedCallback
, I can't cast the DependencyObject
to FileInfo
type.
public static readonly DependencyProperty TargetFileProperty =
DependencyProperty.Register("TargetFile", typeof(System.IO.FileInfo), typeof(FileSelectGroup), new PropertyMetadata(propertyChangedCallback: new PropertyChangedCallback());
private PropertyChangedCallback OnTargetFileChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var f = (System.IO.FileInfo)d; // THIS LINE GIVES ERROR BELOW
}
Error is:
Cannot convert type 'System.Windows.DependencyObject' to 'System.IO.FileInfo'
I thought maybe I was missing something obvious (I probably am) but Microsoft and this answer seem to agree I'm doing roughly the right thing.