Click here to Skip to main content
Click here to Skip to main content

WPF.MichaelAgroskin

By , 6 Oct 2011
 

Introduction

This page and the source code will be updated from time to time, so bookmark it and stay tuned.

Since the library is a work in progress, there could be a few undocumented classes and files. Ignore them please, or use at your risk. If it is not documented, it is probably not finished or not working properly yet.

Of course, the code can be used free of charge provided that the copyright statements stay intact. And of course, Michael Agroskin accepts no responsibility whatsoever for any crashes, errors, or data losses occurring as a result of using this library. Hopefully, there will be no such things, but better be safe than sorry.

Anyway, I hope that you will find those utility classes and controls very useful. At least, it won’t hurt you to take a look and maybe to learn something new. I created those classes out of sheer desperation when nothing else worked, and I have to use some of them every time I write the WPF stuff.

Library

  • {} Adorners
    • AdornerUtils.cs
    • TemplatedAdorner.cs
  • {} Animations
  • {} AutoComplete
    • AutoCompleteUtils.cs
  • {} Behaviours
    • EventBehaviourFactory.cs - Provides utility classes making it easy to execute commands when routed (or regular .NET) events are raised on WPF elements. Example of usage:
      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 - Allows delegating the commanding logic to methods passed as parameters, and enables a View to bind commands to objects that are not part of the element tree (i.e. ViewModel). Very useful in conjunction with EventBehaviourFactory. See example:
         class ViewModel
         {
            public ICommand SomeCommand { get; private set; }
            public ViewModel()
            {
                SomeCommand = new DelegateCommand(
                   () => { ... }, 
                   () => { ... });
            }
         }
         <textbox xxx:textchangedcommand="{Binding SomeCommand}" />
    • TextBoxCommands.cs - Defines DefaultCommand (and DefaultCommandParameter) attached property which can be bound to ICommand and executed when Enter key is pressed. Idea is similar to 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 – Allows to define Booleans inline in any context (and don't rely on the correct TypeConverter). Especially useful when the type of property is "object", i.e., no TypeConverter is used at all. See example:
      <setter value="{ext:Boolean True}" property="..." />
    • DateTimeExtension.cs - See above
    • DoubleExtension.cs - See above
    • EnumExtension.cs - See above
    • Int32Extension.cs - See above
  • {} Helpers
    • DelayedAction.cs
    • DelegateEqualityComparer.cs
    • DummyTypeConverter.cs
    • LookupItem.cs
    • Ref.cs
    • Serializer.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

License

This article, along with any associated source code and files, is licensed under The Eclipse Public License 1.0

About the Author

Michael Agroskin
Software Developer (Senior) Liquidnet
United States United States
Member
Michael is a software developer who still remembers punch cards, computers with 4 Kbytes RAM, and 3270s. His personal computers were Apple IIe, Commodore, and PC XT (with the whole 640 Kbytes RAM and 2 floppy drives!!!). Wow, that was a powerhouse.
 
Fast forward 32 years through FORTRAN, PL-I, Algol, Pascal, Prolog, LISP, C, Basic, Clipper, Assembly, FoxPro, DHTML, JavaScript, C++, you name it, to C# 4.0.
 
Of course, real men use machine code to write software, but what a difference a few years make! No more mallocs and callocs, GC magically collects unused objects, dynamic objects magically call IUnknown::QueryInterface, Reflection magically gives you metadata and even generates help files, WPF magically binds stuff together...
 
Read some of Michael's articles here.
 
BindingHub (a WPF component and a design pattern) [^].
 
Notifying parent of changes to children's properties [^].
 
Point-In-Time database (coming soon)
 
Composite Menus and other ItemsControls (coming soon)
 
Adorners framework (coming soon)
 
Drag-n-drop data transfer framework (coming soon)
 
Converters and MarkupExtensions (coming soon)
 
Download complete WPF library [^].

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberfredatcodeproject6 Oct '11 - 23:32 
GeneralRe: My vote of 5memberRugbyLeague7 Oct '11 - 3:08 
GeneralMy vote of 5memberHari Om Prakash Sharma6 Oct '11 - 17:53 
GeneralMy vote of 5memberWooters6 Oct '11 - 13:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 6 Oct 2011
Article Copyright 2011 by Michael Agroskin
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid