作为我一直试图与WPF/XAML达成一致的一部分,我对将流畅接口应用于UI编码感兴趣。有没有流利的WPF项目?
我知道流利的Silverlight(http://code.google.com/p/fluent-silverlight/),但我似乎无法找到任何等效WPF。
正如我个人而言,我发现很难购买到在XAML和C#/ MVVM的组合做的一切。在我看来,UI编程的某些方面(如数据绑定)在代码中比在声明式XAML中更好。
说一口流利的WPF界面似乎只是实现这些目标的事情。
作为我一直试图与WPF/XAML达成一致的一部分,我对将流畅接口应用于UI编码感兴趣。有没有流利的WPF项目?
我知道流利的Silverlight(http://code.google.com/p/fluent-silverlight/),但我似乎无法找到任何等效WPF。
正如我个人而言,我发现很难购买到在XAML和C#/ MVVM的组合做的一切。在我看来,UI编程的某些方面(如数据绑定)在代码中比在声明式XAML中更好。
说一口流利的WPF界面似乎只是实现这些目标的事情。
在最近的羊群代码播客:客人http://herdingcode.com/?p=212一个讨论,他们试图一口流利的界面,用于创建用户界面WPF。他们中的一个可能会让他们所做的事情变得可能。顺便说一句,这个播客和它之前的播客(http://herdingcode.com/?p=208)分别讲述了您对代码优先和视图优先的关注,以及为什么有必要关注xaml。
的争论主要是有关使用户界面“可混合”(能够设计他们在Microsoft Expression Blend),设计者除了你的代码的可测试性。如果你不是非常小心,基于代码的方法会降低这种能力。
你不是一个人在你的疑虑。希望这些播客能帮助你做出决定。
当我碰上,我宁愿在流利式编程WPF的部分建筑的命令,我加上支持扩展方法到个人应用组件流利的API。
例如,下面的程序演示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);
}
}
}
下面是一口流利的版本:
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));
}
}
}
流畅的版本是采用两个扩展方法,AddChildren
(而不是Children.Add
)和AddClick
(而不是Click += ...
)。
程序是这样的:
我把我的个人FluentWpf
library on github。
谢谢。 我已经听了这两个播客,并且实际上决定调查流畅的silverlight,因为他们。 WPF包含很多很酷的东西 - 它只是一个搞清楚如何最好地使用(和打包)它们的问题。我曾经想过与MFC相当的MFC,但流畅的界面似乎是一个更好的方法。 其他人是否知道WPF的其他平衡评估?即既不完全负面也不完全盲目接受? – kmontgom 2009-08-28 19:41:36
我还没有听说过很多。大多数人都喜欢我碰到的Xaml。这真的很糟糕。我个人喜欢它,现在很多。我认为,如果我不得不去流畅的界面,我可能会觉得很麻烦,如果你能相信的话。 – 2009-08-29 05:48:15
我喜欢使用XAML,但我想强烈的打字和其他类型的编译类型检查Fluent接口或任何其他基于代码的方法可以提供的想法。处理数据绑定XAML的一部分内容是,您觉得自己回到Web上做试验和错误代码,并运行应用程序以查看它是否适用于编程类型。我宁愿将其留给测试人员,但更糟糕的是测试人员甚至不会在默认情况下看到绑定错误,所以我们必须介绍我们自己处理WPF错误以从测试人员那里获得测试人员的反馈。游民。 – jpierson 2011-04-02 05:56:05