をコマンドを構築するために、私は個人的なユーティリティアセンブリにサポートする拡張メソッドを追加します。
たとえば、TaskbarItemInfo
ProgressValue
およびProgressState
のプロパティを示すプログラムは次のとおりです。このバージョンは標準的な流暢な方法で書かれています。ここ
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);
}
}
}
は流暢のバージョンの:流暢バージョンは、(代わりClick += ...
の)
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));
}
}
}
(代わりChildren.Add
の)2つの拡張方法、AddChildren
を採用し、AddClick
れます。私はlibrary on githubFluentWpf
私の個人を保つ
![enter image description here](https://i.stack.imgur.com/gelHb.png)
:
プログラムは次のようになります。
ありがとうございました。 私は両方のポッドキャストに耳を傾け、実際に流暢なシルバーライトを調べることにしました。 WPFにはクールなものがたくさん含まれています。WPFにはクールな使い方が分かります。 自分自身の出会いの危険があるので、私はWPFに相当するMFCについて考えていましたが、流暢なインターフェイスはより良いアプローチのようです。 WPFの他のバランスのとれた鑑定について他の人が知っていますか?私。完全に否定的でもなく、完全に盲目的に受け入れてもいない – kmontgom
私はあまり聞いたことがありません。ほとんどの人が私が遭遇したXamlを受け入れています。それは本当に悪いです。私は今、個人的にはそれが大好きです。私は流暢なインターフェースに行かなければならないと思いますが、あなたがそれを信じることができれば面倒です。 –
私はXAMLでの作業が好きですが、Fluent Interfaceやその他のコードベースのメソッドが提供できる強力な型付けや他のタイプのコンパイル・タイプ・チェックの考え方が欲しいです。データバインディングXAMLを扱うという言葉の部分は、試行錯誤コードを実行しているWeb上にいるように感じ、アプリケーションを実行してプログラミングの種類に対応しているかどうかを確認することです。私はむしろそれをテスターに任せておきますが、さらに悪いことに、テスターはデフォルトでバインディングエラーも見られないので、WPFエラーの処理を導入してテスターからのフィードバックを得る必要があります。バマー。 – jpierson