Sometimes it happens that a ICommand shold be called with a specific parameter only.
To have this it is needed to get the object parameter and cast it to the right type.
ClosingCommand = new DelegateCommand(WindowClosing);
public ICommand ClosingCommand { get; set; }
private void WindowClosing(object arg)
{
var e = (WindowClosingArgs)arg;
}
To prevent this senseless casting I have created an additional DelegateCommand which takes the corresponding object type.
ClosingCommand = new DelegateCommand<WindowClosingArgs>(WindowClosing);
public ICommand ClosingCommand { get; set; }
private void WindowClosing(WindowClosingArgs e)
{
}
Supported with the current DW.SharpTools are both. The non generic DelegateCommand passes just objects.
Facts:
Library: DW.SharpTools
Version: 12.1.11.0
Date: 2012-1-11 20:57
The WPF Window has the problem that not all events from the Win API are represented by a C# event. For example the right click in the title bar or just moving the window itself.
To get such events I have created the WindowBehavior in the DW.SharpTools.
Now, to have the same connected to ICommands, I have added two attach dependency properties to the WindowBehavior in the DW.Interactivity.
With them it is possible to say which Win API events will be forwarded to a command by the IDs. For instance:
<Window Interactivity:WindowBehavior.WinApiMessages="0x216;0x214"
Interactivity:WindowBehavior.WinApiCommand="{Binding WinApiCommand}">
</Window>
public partial class DemoWindow : Window
{
public DemoWindow()
{
WinApiCommand = new DelegateCommand(WinApi);
}
public ICommand WinApiCommand { get; set; }
private void WinApi(object arg)
{
var e = (NotifyEventArgs)arg;
if (e.MessageId == WindowMessages.WM_MOVING)
//...
}
}
The messages can be written in hex values like Microsoft write them in the MSDN like "0x216;0x214" but also the integers are possible, like "3;4".
To get all Win API messages, just "All" have to be written.
Facts:
Library: DW.Interactivity
Version: 12.1.7.0
Date: 2012-1-9 18:24
Now it is December, 31th 2011 at about 7 o'clock PM and I'm finish with moving all the stuff from the DW.WPFDev to the DW.SharpTools and impement the last unit test (100% code coverage).
(Yesterday I have reimplemented the WindowObserver, I think its is much more better now
)
Tomorrow, in the new year, I think I can deploy the new DW.SharpTools and the other (because of the dependency) which finishes the shrinking process and I can start new challenges in the next year.
Ending with passing unit tests is a great sign 
The DW.Configurations and DW.Loggings are gone.
The DW.UnitTests is integrated into the DW.Services.
The DW.Localiation and DW.XmlTools are integrated into the DW.SharpTools.
Now just the DW.WPFDev stays left, as soon I have integrated it into the DW.SharpTools the internal dependency of the WPFToolkit changes from the DW.WPFDev to the DW.SharpTools as well.
All projects with the state before the delete and the merges can be downloaded from the Miscellaneous section.
Hi,
Currently I have 10 libraries online. My plans are to shrink them down to just 4 libraries. That means on the end that some libraries will die and some will be merged.
Currently I have:
DW.Configurations = An alternative application settings management
DW.Interactivity = Interactivity between WPF Controls and C#
DW.Localization = Tools for localization in general
DW.Logging = Provides some logging functionality
DW.Services = Services to be used in a MVVM environment
DW.SharpTools = Common classes for C# applications
DW.UnitTests = unit test implementations of the services
DW.WPFDev = Some helpfully classes for developing
DW.WPToolkit = Custom WPF controls
DW.XmlTools = Objects for an easy working with XML files
Soon I will just have:
DW.Interactivity
DW.Services
DW.SharpTools
DW.WPFToolkit
These are the changes to achieve this:
DW.Configurations will be deleted
DW.Localizations will be merged into the DW.SharpTools
DW.Logging will be deleted
DW.UnitTests will be merged into the DW.Services
DW.WPFDev will be merged into the DW.SharpTools
DW.XmlTools will be merged into the DW.SharpTools
(I will put the repositories of the projects I delete into an archive directory)
If someone has any problems with this plans, just concact me and we can speak about.