Thank you for the response. I think I am getting close, however, I am unable to get the file dialog to bind back the Xceed Property item.
public FrameworkElement ResolveEditor(PropertyItem propertyItem)
{
var file = String.IsNullOrEmpty(propertyItem.Value?.ToString()) ? "Select File..." : propertyItem.Value?.ToString();
var editField = new Button();
editField.Content = file;
editField.Click += (s, a) =>
{
var newFile = GetFile(propertyItem.Value?.ToString());
propertyItem.Value = newFile;
editField.Content = newFile;
};
var binding = new Binding("Value");
binding.Source = propertyItem;
binding.ValidatesOnExceptions = true;
binding.ValidatesOnDataErrors = true;
binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(editField, TextBox.TextProperty, binding);
return editField;
}
private String GetFile(String initial)
{
var dlg = new OpenFileDialog();
dlg.CheckFileExists = true;
dlg.RestoreDirectory = true;
dlg.Multiselect = false;
dlg.DefaultExt = "*.SAI";
dlg.Filter = "Sage Files|*.SAI";
dlg.InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Simply Accounting/DATA");
if(!Directory.Exists(dlg.InitialDirectory))
{
dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
}
var result = dlg.ShowDialog();
if(!result.HasValue)
{
return "";
}
if(result.Value)
{
return dlg.FileName;
}
return initial;
}
}
After the user selects a file, the button id updated to display the filename, but the property does not get set on the settings object. What am I missing?