|
Hi guys, thank you for your interest in Grapfh# control.
Please, do not ask a question on another question. Would be better open two separate topic.
@windz82
To achive your goal, you can use a DataTrigger that
set the background color of your vertex after mouse over. Take a look at following code:
<DataTemplate
DataType="{x:Type
common_graph:EntityVertex}">
<Border
x:Name="vertexBorder">
<StackPanel
ToolTip="{Binding
Path=Description}"
x:Name="vertexPanel">
<TextBlock />
</StackPanel>
</Border>
<DataTemplate.Triggers>
<DataTrigger
Binding="{Binding
Path=IsSelected}"
Value="True">
<Setter
TargetName="vertexBorder"
Property="BorderBrush"
Value="Black"></Setter>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
In this example, I set a DataTemplate for
my vertex (EntityVertex in my domain) with a DataTrigger that
set the border to black where a user select a vertex. When the user click on a vertex i set True the IsSelected property that fires the datatrigger which set the borderbrush property. .
You can easily follow this example.
@homeshahab
Of course is possible, for example you can define a property that will discriminate the color of you vertex, and with datatrigger set the color based on its value. Look at the previous example, you
can set color based on id (for example)
<DataTrigger
Binding="{Binding
Path=Id}"
Value="1">
<Setter
TargetName="vertexBorder"
Property="Backgroundcolor"
Value="Black"></Setter>
</DataTrigger>
<DataTrigger
Binding="{Binding
Path= Id }"
Value="2">
<Setter
TargetName="vertexBorder"
Property="
Backgroundcolor "
Value="White"></Setter>
</DataTrigger>
<DataTrigger
Binding="{Binding
Path= Id }"
Value="3">
<Setter
TargetName="vertexBorder"
Property="
Backgroundcolor "
Value="Orange"></Setter>
</DataTrigger>
This is the way.
I bet you have a lot of vertices and several color to set. You can do it programmatically to make dynamic the color association. If you need more help, please contact me.
Enjoy coding!
badagn
|