65.9K
CodeProject 正在变化。 阅读更多。
Home

WPF.MichaelAgroskin

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.65/5 (8投票s)

2011年10月6日

Eclipse

3分钟阅读

viewsIcon

29220

downloadIcon

718

一个免费的 WPF 控件和 C# 实用类库。

引言

此页面和源代码将不定期更新,请添加书签并保持关注。

由于该库仍在开发中,可能存在一些未记录的类和文件。请忽略它们,或自行承担风险。如果未记录,则可能尚未完成或尚未正常工作。

当然,在版权声明保持不变的情况下,可以免费使用该代码。当然,Michael Agroskin 对因使用此库而导致的任何崩溃、错误或数据丢失概不负责。希望不会出现这种情况,但小心总比后悔好。

无论如何,我希望您会发现这些实用程序类和控件非常有用。至少,看一看,也许还能学到一些新东西,这对您没有坏处。当无计可施时,我出于绝望创建了这些类,并且每次编写 WPF 代码时都必须使用其中的一些类。

  • {} Adorners (修饰)
    • AdornerUtils.cs
    • TemplatedAdorner.cs
  • {} Animations (动画)
  • {} AutoComplete (自动完成)
    • AutoCompleteUtils.cs
  • {} Behaviours (行为)
    • EventBehaviourFactory.cs - 提供了实用程序类,使在 WPF 元素上引发路由(或常规 .NET)事件时易于执行命令。使用示例
      public static class TextBoxBehaviour
      {
          public static readonly DependencyProperty TextChangedCommand = 
          RoutedEventBehaviourFactory.CreateCommandExecutionEventBehaviour
          (TextBox.TextChangedEvent, 
      	"TextChangedCommand", typeof (TextBoxBehaviour));     
          public static void SetTextChangedCommand
      		(DependencyObject o, ICommand value)
          {
              o.SetValue(TextChangedCommand, value);
          }
          public static ICommand GetTextChangedCommand(DependencyObject o)
          {
              return o.GetValue(TextChangedCommand) as ICommand;
          }
          // Optional
          public static readonly DependencyProperty TextChangedCommandParameter = 
          RoutedEventBehaviourFactory.CreateCommandParameter(TextChangedCommand);
          public static void SetTextChangedCommandParameter
      			(DependencyObject o, object value)
          {
              o.SetValue(TextChangedCommandParameter, value);
          }
          public static object GetTextChangedCommandParameter(DependencyObject o)
          {
              return o.GetValue(TextChangedCommandParameter);
          }
      }
      
          <textbox xxx:textchangedcommandparameter="{Binding ...}" 
      		xxx:textchangedcommand="{Binding SomeCommand}" />
  • {} Bindings (绑定)
  • {} Collections (集合)
  • {} Commands (命令)
    • DelegateCommand.cs - 允许将命令逻辑委托给作为参数传递的方法,并使 View 能够将命令绑定到不属于元素树的对象(即 ViewModel)。与 EventBehaviourFactory 结合使用非常有用。 见示例
         class ViewModel
         {
            public ICommand SomeCommand { get; private set; }
            public ViewModel()
            {
                SomeCommand = new DelegateCommand(
                   () => { ... }, 
                   () => { ... });
            }
         }
         <textbox xxx:textchangedcommand="{Binding SomeCommand}" />
    • TextBoxCommands.cs - 定义 DefaultCommand (和 DefaultCommandParameter)附加属性,该属性可以绑定到 ICommand 并在按下 Enter 键时执行。想法类似于 EventBehaviourFactory
  • {} Common (公共)
  • {} Converters (转换器)
    • AddConverter.cs
    • BooleanValueConverter.cs
    • BrushValueConverter.cs
    • ByteValueConverter.cs
    • CharValueConverter.cs
    • ColorValueConverter.cs
    • CombineFlagsConverter.cs
    • ConverterEnums.cs
    • DateTimeValueConverter.cs
    • DecimalValueConverter.cs
    • DelegateConverter.cs
    • DelegateMultiConverter.cs
    • DoubleValueConverter.cs
    • EditableFlagsToBooleanConverter.cs
    • EnumToBooleanConverter.cs
    • EnumValueConverter.cs
    • FlagsToBooleanConverter.cs
    • GridLengthValueConverter.cs
    • NotConverter.cs
    • ObjectToObjectConverter.cs
    • ThicknessValueConverter.cs
    • TimeSpanValueConverter.cs
  • {} Delegates (委托)
  • {} DragDrop (拖放)
    • DataConsumer.cs
    • DataConsumerFactory.cs
    • DataObjectBase.cs
    • DataProvider.cs
    • DataProviderFactory.cs
    • DataTransfer.cs
    • DragDropConsts.cs
  • {} Extensions (扩展)
    • BooleanExtension.cs – 允许在任何上下文中内联定义布尔值(并且不依赖于正确的 TypeConverter)。当属性的类型为 "object" 时特别有用,即根本不使用 TypeConverter 。 见示例
      <setter value="{ext:Boolean True}" property="..." />
    • DateTimeExtension.cs - 见上文
    • DoubleExtension.cs - 见上文
    • EnumExtension.cs - 见上文
    • Int32Extension.cs - 见上文
  • {} Helpers (帮助程序)
    • DelayedAction.cs
    • DelegateEqualityComparer.cs
    • DummyTypeConverter.cs
    • LookupItem.cs
    • Ref.cs
    • Serializer.cs
    • WindowBehavior.cs
  • {} Menus (菜单)
    • CompositeContextMenu.cs
    • CompositeMenu.cs
    • CompositeMenuItem.cs
    • FlatteningMenuItems.cs
  • {} ReadOnly (只读)
    • ReadOnlyClone.cs
    • ReadOnlyCloneFactory.cs
  • {} Threading (线程处理)
    • MultiThreadedWrapper.cs
    • ThreadedVisualHelper.cs
    • ThreadingUtils.cs
  • {} Visuals (视觉)
    • VisualTargetPresentationSource.cs
    • VisualWrapper.cs
  • {} WeakEvents (弱事件)
© . All rights reserved.