How can i get the vertex object info when i click on the vertex?

Nov 19, 2012 at 9:29 PM

The problem is that the Graph representation is hidden because the Graph is built via

<zoom:ZoomControl  Grid.Row="1"  Zoom="0.2"         ZoomBoxOpacity="0.5" Background="#ff656565">       

<local:VisGraphLayout x:Name="graphLayout" Margin="10"        Graph="{Binding Path=Graph}"        LayoutAlgorithmType="{Binding Path=LayoutAlgorithmType, Mode=OneWay}"        OverlapRemovalAlgorithmType="FSA"        HighlightAlgorithmType="Simple" />
       </zoom:ZoomControl>

 

Is there a way to reach the Vertex object while accesing the onClick method?

Nov 23, 2012 at 3:19 AM

Hi galexia1000,

If I understand correctly you are trying to intercept the click event of a vertex in order to do something with it.

This XAML code modifies the control to allow you to hook into mouse events. This works basically for any event type:

<Style TargetType="{x:Type graphsharp:VertexControl}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type graphsharp:VertexControl}">
                        <Border BorderBrush="White" 
                            Background="Black"
                            BorderThickness="2"
                            CornerRadius="10,10,10,10"
                            Padding="{TemplateBinding Padding}"
                            MouseDown="YOUR_METHOD"
                            MouseUp="ANOTHER_METHOD"
                            MouseMove="ETC">
                            
                            <ContentPresenter Content="{TemplateBinding Vertex}" 
                                ContentTemplate="{StaticResource vertexTemplate}" />
			 <!-- The vertextTemplate refers to the DataTemplate containing your vertex data -->
                            <Border.Effect>
                                <DropShadowEffect BlurRadius="2" Color="LightGray" 
                                    Opacity="0.3" Direction="315" />
                            </Border.Effect>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>