Introduce DataBase,Asp.net,JavaScript,Xml,Html,Css,Sql,Php,ASP.NET Controls,AJAX,Tools,HTML,CSS,JavaScript,Open Source Project,WPF,.Net Framework,Linq
Top Recommended Hosting

WPF DoubleClickCommand in Xaml

by the3factory 4/2/2008 6:31:00 AM
Download code
 

Some classes like Button an MenuItem provided a property named Command which makes coding simplier, but most other classes do not provide same kind of functionality for each events.

I want to implement a Command for DoubleClick, I did tried Googled, there are some solution included using EventSetter or something like that, but it is too complicated for me, so I developed a new control just for doing that.

Background

The control is very simple...(96 lines), it is actually a DockPanel which you can used to host your control (which implement doubleclick).

Using the code

<Window x:Class="WPF_DirectoryLister_DMVVM.Window1"
xmlns:control="clr-namespace:QuickZip.Windows.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="600">
<Grid>
<control:TrapDoubleClick>
<Label control:TrapDoubleClick.Command="ApplicationCommands.Help">
DoubleClickMe
</Label>
</control:TrapDoubleClick>
</Grid>
</Window>         

Points of Interest

Took me a while to figure out, if you want to override OnMouseLeftButtonDown method, you will have to set Control.AllowDrop to true.

Related posts

Sign up for PayPal and start accepting credit card payments instantly.


Powered by BlogEngine.NET 1.2.0.0