Comments (2)
Hello! Recently I've solved similar problem. I used Devexpress EventToCommand to do this, but I think You can use another binding here.
Here is my XAML code:
<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.
from graphx.
// Assume you have a ZoomControl defined in XAML similar to below:
<graphx:ZoomControl x:Name="ErgZoomctrl" Margin="5,0,5,0" Grid.Row="1" Grid.Column="0"
Grid.ColumnSpan="2"
ViewFinderVisibility="{Binding ViewFinderVisibility}" Background="WhiteSmoke">
<models:GraphAreaEx x:Name="ErgArea"/>
</graphx:ZoomControl>
// Subscribe to the Event handler.
ErgArea.VertexDoubleClick += ErgArea_OnVertexDoubleClick;
// This event handler is only needed if you need to expose this event for subscribing externally from a UserControl.
public event VertexSelectedEventHandler VertexDoubleClick;
// 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.
internal virtual void OnVertexDoubleClick(VertexControl vc, MouseButtonEventArgs e)
{
VertexSelectedEventHandler vertexDoubleClick = this.VertexDoubleClick;
if (vertexDoubleClick == null)
return;
// This handler init is optional.
vertexDoubleClick((object) this, new VertexSelectedEventArgs(vc, (MouseEventArgs) e, Keyboard.Modifiers));
}
subscribe to the VertexDoubleClick Event Handler
from graphx.
Related Issues (20)
- The sample application not building
- [MVVM] Vertices text is not showing up correctly HOT 2
- Background Image of Vertex HOT 3
- How to remove label edge? HOT 2
- How to remove minimap of the view finder?
- How to export graph to png?
- Slow Drag Vertex
- Implementation of the mvvm model with GraphX
- Initialization error on pass false to tracePositionChange of VertexControl Constructor
- Graph virtualization
- is it possible to add new verticies/edges without having a full relayout of the graph?
- How to make arrows?
- How to make edges doesn't cross HOT 3
- How to change the type of edges?
- Release nuget version with support for QuikGraph HOT 2
- recent development HOT 1
- strange behavior HOT 2
- Edges with same source and target rendered as a star instead of an edge? HOT 1
- the additional api website is currently unavailable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphx.