I am having trouble databinding a TextBox.Text
property to a object\'s method. The idea is allowing the user to write in a TextBox
a file name and then
Databinding requires the NotifyPropertyChanged
event to be called when the source is updated. In this case, you'd want to wrap this function call in a get/set like so:
public class FileWrapper: System.ComponentModel.INotifyPropertyChanged{
private string m_filename;
public string FileExtension{
get{ return GetFileExtension(FileName);}
}
public string FileName{
get{ return m_filename;}
set{ m_filename = value; OnPropertyChanged("FileName"); OnPropertyChanged( "FileExtension");
}
public string GetFileExtension( string filename){
//implementation
}
public event System.ComponentModel.NotifyPropertyChangedEvent PropertyChanged = (a,b)=>{};
protected void OnPropertyChanged(string property){
PropertyChanged( this, new System.ComponentModel.PropertyChangedEventArgs( property ));
}
}