WPF.MichaelAgroskin






4.65/5 (8 votes)
A free library of WPF controls and C# utility classes
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}" />
- 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:
- {}
Bindings
- BindingHub.cs - BindingHub (a WPF component and a design pattern) [^]
- BindingHubConnection.cs - See above
- BindingHubConnectionConverter.cs - See above
- BindingHubEnums.cs - See above
- BindingUtils.cs - See above
- {}
Collections
- NotifyParentObservableCollection.cs - Notifying parent of changes to children's properties [^]
- {}
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 withEventBehaviourFactory
. See example:
class ViewModel { public ICommand SomeCommand { get; private set; } public ViewModel() { SomeCommand = new DelegateCommand( () => { ... }, () => { ... }); } } <textbox xxx:textchangedcommand="{Binding SomeCommand}" />
- TextBoxCommands.cs - Defines
DefaultCommand
(andDefaultCommandParameter
) attached property which can be bound toICommand
and executed when Enter key is pressed. Idea is similar toEventBehaviourFactory
.
- 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.
- {}
Common
- ChildPropertyChanged.cs - Notifying parent of changes to children's properties [^]
- {}
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
- DelegateUtility.cs - Allows casting between arbitrary delegate types. Kudos to Ed Ball [^]
- {}
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., noTypeConverter
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
- BooleanExtension.cs – Allows to define Booleans inline in any context (and don't rely on the correct
- {}
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
- AnyPropertyChangedEventManager.cs - Notifying parent of changes to children's properties [^].
- ChildPropertyChangedEventManager.cs - See above