Using WPF & C#, how to show uploaded files as Hyperlinks with a delete button for each file -
using wpf & c#, how show uploaded files hyperlinks, giving delete button each file, can delete 1 file @ time if not required. able show files mere text in textbox. how proceed further. can me please.??
well going need enumerate files start ienumerable<string> system.io.directory.enumeratefiles(string path)
.
this of course need exposed view can create ui each item. done list
<listbox itemssource="{binding listoffiles}"> <listbox.itemtemplate> <datatemplate>
to create hyperlink use hyperlink inside textblock such
<textblock> <hyperlink command="{binding deletecommand}" commandparameter="{binding}" text="{binding}" /> </textblock>
you notice i'm binding deletecommand expects have pararmeter passed it, parameter same text displayed in link. i'd choose on trying clicked
since filename.
how implement command
, whether there default command implementation in whichever mvvm framework want use. if aren't using 1 can use relaycommand josh smith's original mvvm article
relaycommand _deletecommand; public icommand deletecommand { { if (_deletecommand == null) { _deletecommand = new relaycommand( param => this.delete(param), param => this.candelete(param)); } return _deletecommand; } }
you need provide implementations bool candelete(sting filename)
maps directly system.io.file.exists(filename)
, void delete(string filename)
maps system.io.file.delete(filename)
.
Comments
Post a Comment