The official code sample can be found at CodePlex . As the CodePlex closes soon, here is the squeeze:
// ΠΌΠΎΠ΄Π΅Π»Ρ double progress; double Progress { get => progress; set { if (progress != value) { progress = value; // ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΡΠ΅ Π½ΠΎΡΠΈΡΠΈΠΊΠ°ΡΠΈΡ ΠΎΠ± ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ΅ΡΡΠ° } } }
Progress = 0; cmpr.Compressing += OnCompressingProgress; cmpr.CompressionFinished += OnCompressionFinished; cmpr.BeginCompressFiles(...); // Π°ΡΠΈΠ½Ρ
ΡΠΎΠ½Π½Π°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ
void OnCompressingProgress(object sender, ProgressEventArgs e) => Progress += e.PercentDelta / 100.0; void OnCompressionFinished(object sender, EventArgs e) { Progress = 1.0; var cmpr = (SevenZipCompressor)sender; cmpr.Compressing -= OnCompressingProgress; cmpr.CompressionFinished -= OnCompressionFinished; }
At the VM level, you need to subscribe for notifications from the model, perhaps smashall them into a UI thread, and update the CompressionProgress INPC property. (This is a different property, not one that is in the model!)
At the View level, you simply bind to the CompressionProgress property of the VM:
<ProgressBar Value="{Binding CompressionProgress}" Minimum="0" Maximum="1"/>
Like everything.
SevenZipCompressorgive messages about the progress of the operation? - VladD