panthernet / GraphX

GraphX for .NET
Apache License 2.0
309 stars 101 forks source link

Background Image of Vertex #103

Open josse995 opened 5 years ago

josse995 commented 5 years ago

Hello everyone!

I am trying to set an image as background of a vertex, but I don't find how to do it. It is possible to do this? If it is possible, how could I do it?

Thanks!

panthernet commented 5 years ago

Hi, you should change the VertexControl template in XAML. This is the default template:

    <Style TargetType="{x:Type graphx:VertexControl}">
        <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"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type graphx:VertexControl}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            CornerRadius="10,10,10,10"
                        Padding="{TemplateBinding Padding}">
                        <Grid>
                            <ContentPresenter Content="{TemplateBinding Vertex}" />
                            <graphx:VertexLabelControl x:Name="PART_vertexLabel" Content="{Binding Vertex, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="graphxRoot:GraphAreaBase.PositioningComplete" Value="False">
                <Setter Property="Visibility" Value="Hidden"/>
            </Trigger>
        </Style.Triggers>
    </Style>
josse995 commented 5 years ago

Thank you for the reply! Thanks to you response, I started thinking that VertexControl is like a container, and then, I find out easy to add whatever you want!

Thank you for your hard work! (Sorry for the late response BTW :( )

panthernet commented 5 years ago

np, have fun!