I want to achieve the following:
Create a WPF DataGrid that have 2 columns:
The first will have items showing paths to directories, in a hyperlink style. Clicking on a hyperlink will open Windows Explorer in the path specified by the item.
The second will have items showing paths to files, in a hyperlink style. Clicking on a hyperlink will launch the file, with the default application defined by Windows.
I don’t know if it’s the right choice, but I added DataGridHyperlinkColumn’s to my DataGrid. One problem was to add Uri items that do not refer to an internet locations. Another problem was to handle the clicks in a way that does not open a web browser.
Anyone can help?
This works universally:
If the URI points a website it will be opened with the default web-browser, if it is a folder it will be opened in explorer, if it is a file it will be opened with the default application associated with it.
To use this for autogenerated columns your property needs to be of type
Uriso aDataGridHyperlinkColumnis generated. You then can hook up the event by placing the style in theDataGrid.Resources: