As I come across parts of WPF that I prefer to run fluently, I add helper extension methods to my personal assembly.
For example, here is a program that demonstrates the properties of TaskbarItemInfo ProgressValue and ProgressState . This version is written in a standard fuzzy way.
using System.Windows; using System.Windows.Controls; using System.Windows.Shell; namespace TaskbarItemProgress { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); TaskbarItemInfo = new TaskbarItemInfo(); TaskbarItemInfo.ProgressValue = 0.5; var stackPanel = new StackPanel(); Content = stackPanel; var normalButton = new Button() { Content = "Normal" }; normalButton.Click += (s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; stackPanel.Children.Add(normalButton); var pausedButton = new Button() { Content = "Paused" }; pausedButton.Click += (s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused; stackPanel.Children.Add(pausedButton); var errorButton = new Button() { Content = "Error" }; errorButton.Click += (s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error; stackPanel.Children.Add(errorButton); var indeterminateButton = new Button() { Content = "Indeterminate" }; indeterminateButton.Click += (s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate; stackPanel.Children.Add(indeterminateButton); var noneButton = new Button() { Content = "None" }; noneButton.Click += (s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; stackPanel.Children.Add(noneButton); var increaseButton = new Button() { Content = "Increase" }; increaseButton.Click += (s, e) => TaskbarItemInfo.ProgressValue += 0.10; stackPanel.Children.Add(increaseButton); var decreaseButton = new Button() { Content = "Decrease" }; decreaseButton.Click += (s, e) => TaskbarItemInfo.ProgressValue -= 0.10; stackPanel.Children.Add(decreaseButton); } } }
Here is the free version:
using System.Windows; using System.Windows.Controls; using System.Windows.Shell; using FluentWpf; namespace TaskbarItemProgress { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); TaskbarItemInfo = new TaskbarItemInfo(); TaskbarItemInfo.ProgressValue = 0.5; Content = new StackPanel() .AddChildren( new Button() { Content = "Normal" } .AddClick((s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal), new Button() { Content = "Paused" } .AddClick((s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Paused), new Button() { Content = "Error" } .AddClick((s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error), new Button() { Content = "Indeterminate" } .AddClick((s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate), new Button() { Content = "None" } .AddClick((s, e) => TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None), new Button() { Content = "Increase" } .AddClick((s, e) => TaskbarItemInfo.ProgressValue += 0.10), new Button() { Content = "Decrease" } .AddClick((s, e) => TaskbarItemInfo.ProgressValue -= 0.10)); } } }
The free version uses two extension methods, AddChildren (instead of Children.Add ) and AddClick (instead of Click += ... ).
The program is as follows:

I keep my personal FluentWpf library on github .
dharmatech Apr 19 2018-12-12T00: 00Z
source share