I have a .cab
extraction utility. On my main window, I want to show the name of .cab
being extracted, which file is being extracted right now, and the percentage of extraction done.
I have written properties for each field i.e. file name
, percentage
, etc... which are on my ViewModel
.
All is working fine but it is not reflected on UI
MainVindowViewModel
:
public string FileExtract
{
get
{
return _fileExtract;
}
set
{
_fileExtract = value;
NotifyPropertyChanged("FileExtract");
}
}
public int Percent
{
get
{
return _percent;
}
set
{
_percent = value;
NotifyPropertyChanged("Percent");
}
}
Method for extraction
private void ExtractCab(string outputDirectory)
{
m_CabinetFile.FileExtractBefore += new EventHandler(CabinetFile_FileExtractBefore);
m_CabinetFile.FileExtractComplete += new EventHandler(CabinetFile_FileExtractComplete);
}
above two events triggers before and after file is extracted respectively.
With the following methods I get all info that I required when cab is getting extracted, but it is not reflected on UI
private void CabinetFile_FileExtractBefore(object sender, System.EventArgs e)
{
TFile file = (TFile)sender;
FileExtract = file.FullName;
}
private void CabinetFile_FileExtractComplete(object sender, System.EventArgs e)
{
Count++;
Percent = Convert.ToInt32(((decimal)Count / (decimal)m_CabinetFile.FileCount) * 100);
}
FileExtract
and Percent
properties are bound to the XAML UI, which is getting updated in code but not in UI. UI is stuck until complete cab has been extracted.