For a more feature complete answer, assume you have a Button BtnFileOpen
and a textbox TxtFile
. First you need to reference the System.Windows.Forms
assembly from the references dialog (make sure you check mark it, double clicking it didn't seem to add it for me).
Inside the button click event:
private void BtnFileOpen_Click(object sender, RoutedEventArgs e)
{
var fileDialog = new System.Windows.Forms.OpenFileDialog();
var result = fileDialog.ShowDialog();
switch (result)
{
case System.Windows.Forms.DialogResult.OK:
var file = fileDialog.FileName;
TxtFile.Text = file;
TxtFile.ToolTip = file;
break;
case System.Windows.Forms.DialogResult.Cancel:
default:
TxtFile.Text = null;
TxtFile.ToolTip = null;
break;
}
}
If you have set your textbox to disabled you may wish to edit your xaml to include
ToolTipService.ShowOnDisabled="True"