代码之家  ›  专栏  ›  技术社区  ›  kmontgom

有流畅的WPF项目吗?[闭门]

  •  2
  • kmontgom  · 技术社区  · 17 年前

    作为我不断尝试接受WPF/XAML的一部分,我对将流畅的界面应用于UI编码感兴趣。

    http://code.google.com/p/fluent-silverlight/ ),但我似乎找不到任何与WPF等效的东西。

    一个流畅的WPF接口似乎正是实现这些目标所需要的。

    3 回复  |  直到 17 年前
        1
  •  2
  •   Anderson Imes    17 年前

    在最近的一个关于放牧代码的播客上: http://herdingcode.com/?p=212 其中一位来宾讨论说,他们尝试使用流畅的界面来创建WPF UI。有可能他们中的一个能让他们所做的一切成为现实。

    顺便说一句,这个播客和它之前的播客是一样的( http://herdingcode.com/?p=208 )谈谈您对“代码优先”和“视图优先”的担忧,以及为什么专注于xaml是有利的。

    你并不是唯一一个心存疑虑的人。希望这些播客能帮助你做出决定。

        2
  •  2
  •   dharmatech    14 年前

    当我遇到我更喜欢以流畅的风格编程的WPF部分时,我将支持的扩展方法添加到个人实用程序集。

    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));
            }
        }
    }
    

    fluent版本采用了两种扩展方法, AddChildren (而不是 Children.Add )及 AddClick (而不是 Click += ... ).

    enter image description here

    我保留我的个人隐私 FluentWpf library on github .

        3
  •  1
  •   Adam Mills    16 年前

    用于在WPF中生成命令的Fluent API http://code.google.com/p/present/