TAN WhoAMI

TAN WhoAMI

  • NA
  • 291
  • 0

How to have clickable text in WPF DataGrid?

Jul 18 2012 3:16 AM
I have this Field named FileName stored in the WPF DataGrid.. such as it open a dialogbox and user selects the file. The FileName is stored in the DataGrid. I want to make that FileName clickable, such that when user clicks it, it opens the file.



        public void AttachFile_button_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string[] strPath = dlg.FileName.Split(Convert.ToChar(@"\"));
                newServiceReport.FileName = strPath[strPath.Length - 1];
            }

            // Create a hyperlink for the match
            //var link = new Hyperlink(new Run(newServiceReport.FileName))
            //{
            //    NavigateUri = new Uri(newServiceReport.FileName)
            //};
            //link.Click += cnn_Click;


            db.ServiceReportFiles.InsertOnSubmit(newServiceReport);
            db.SubmitChanges();
            ServiceReportDataGrid.ItemsSource = db.ServiceReportFiles.ToList();

        }


The closest link I can find is this: http://stackoverflow.com/questions/9058920/how-to-set-navigation-url-for-text-in-datagrid-column

but it still does not help.

thanks.