Adding a context menu to node

May 6, 2012 at 7:59 AM

How to add a context menu to node?

May 9, 2012 at 5:03 PM

i dont know if mine is a right way to made , but it does the joib

<!-- VERTEX CONTROL -->
    <Style TargetType="{x:Type GraphSharp_Controls:VertexControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate  TargetType="{x:Type GraphSharp_Controls:VertexControl}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="10,10,10,10"
                            Padding="{TemplateBinding Padding}">
                        <Border.ContextMenu>
                            <ContextMenu Opened="ContextMenu_Opened">
                                <MenuItem x:Name="miDelete"               Header="Delete" />
                                <MenuItem x:Name="miAdd" Click="miAdd_Click" Header="elimina"/>
                            </ContextMenu>
                        </Border.ContextMenu>
                        <ContentPresenter Content="{TemplateBinding Vertex}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger" Value="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled" Value="True"/>
        <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.X), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.Y), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="Background" Value="#FFE3E3E3"/>
        <Setter Property="BorderThickness" Value="5,3,5,3"/>
        <Setter Property="Padding" Value="10,5,10,5"/>
        <Setter Property="BorderBrush" Value="#FF393939"/>
        <Style.Triggers>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
                <Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
            </Trigger>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
                <Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Source"/>
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedSourceVertexBorderBrush}"/>
                <Setter Property="Background" Value="{StaticResource SemiHighlightedSourceVertexBackgroundBrush}"/>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
                    <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Target"/>
                </MultiTrigger.Conditions>
                <Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedTargetVertexBorderBrush}"/>
                <Setter Property="Background" Value="{StaticResource SemiHighlightedTargetVertexBackgroundBrush}"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>