-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add double click event to a vertex #118
Comments
Hello! Recently I've solved similar problem. I used Devexpress EventToCommand to do this, but I think You can use another binding here. <Style TargetType="{ x:Type controls:VertexControl }">
...
<--<Different setters here/>-->
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{ x:Type controls:VertexControl }">
<Grid>
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="MouseDown"
Command="{ Binding SelectCmd}"
PassEventArgsToCommand="True"
EventArgsConverter="{ StaticResource MouseEventArgsToBoolIsDoubleClick }" />
</dxmvvm:Interaction.Behaviors>
...
<--Other elements in grid-->
</Grid> And here is args converter. It only returns was double click performed or not. public class MouseEventArgsToBoolIsDoubleClick:IEventArgsConverter
{
public object Convert( object sender, object args )
{
if ( args is MouseButtonEventArgs mouseArgs )
{
return mouseArgs.ClickCount == 2;
}
return false;
} In my DataVertex I have command to process doubleclick: public ICommand SelectCmd { get; set; }
//In Constructor:
SelectCmd = ReactiveCommand.Create<bool>( Select );
//And Method to be assosiated with command.
private void Select( bool isDoubleClick )
{
if ( isDoubleClick )
{
IsSelected = !IsSelected;
}
} Of course You can do all of this simplier, without all this commands and converters. |
// Assume you have a ZoomControl defined in XAML similar to below:
// Subscribe to the Event handler. // This event handler is only needed if you need to expose this event for subscribing externally from a UserControl. // Add the Event Handler. I use this as another custom User Control so I expose this event to the outside world. You can choose to just respond to the mouse double-click event here as an alternative.
subscribe to the VertexDoubleClick Event Handler |
How to add double click event to a vertex (with Dragging set on)
The text was updated successfully, but these errors were encountered: