I have my custom control named "FileSelectDialog" with Dependency Property:
public static readonly DependencyProperty FilePathProperty =
DependencyProperty.Register("FilePath", typeof(string), typeof(FileSelectDialog));
public string FilePath
{
get { return (string)GetValue(FilePathProperty); }
set { SetValue(FilePathProperty, value); }
}
然后,我试图对这种依赖性财产进行约束:
<controls:FileSelectDialog FilePath="{Binding FolderName}"/>
但是,没有任何 ha、我的控制没有初步案文、没有为FolderName财产保留最新案文! 我在产出窗口中发现这种错误:
System.Windows.Data Error: 40 : BindingExpression path error: FolderName property not found on object FileSelectDialog (Name= FolderSelector ) . BindingExpression:Path=FolderName; DataItem= FileSelectDialog (Name= FolderSelector ); target element is FileSelectDialog (Name= FolderSelector ); target property is FilePath (type String )
因此,据我所知,控制试图发现FolderName本身的财产,而控制该财产时父母必须控制数据。 例如,当我使用简单文本框时:
<TextBox Text="{Binding Path=FolderName}"/>
所有人都是工作罚款。