Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Multiple Questions on Diagram Styling (Read 2386 times)
Shakester
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Feb 9th, 2021
Multiple Questions on Diagram Styling
Feb 19th, 2021 at 1:55am
Print Post  
I have several questions related to styling for the diagram nodes and links. I'll enumerate them below:

1.      Styling for a Table Node: Can a table node be styled so that when a mouse rolls over a row, the entire row background color can be changed. This would be similar to a DataGrid.RowStyle where a Style Trigger can be assigned to change the entire row style. I see where it can be assigned to a Table Node Cell but I’d like it for the entire row.

2.      As I could not find a way to handle issue 1, I went down the path of building a TemplatedNode to create my own DataGrid to allow the styling as I needed. I first did this in the sample Tutorial4 and was successful in creating a node to look as I need. I then re-created the same in a new project but when it executes, I continually get the 2 Data Errors below. I cannot figure out where these are coming from as I am not setting the properties described. I have checked multiple times to be sure the code, the xaml and the references are all identical across the 2 projects. The only difference I can find is in the namespaces. I have attached the modified Tutorial4 project (without the Reference folder as the file size was too large) and my Test project (Test123). If someone could explain why these errors are occurring, it would be very helpful. As an FYI, I’m using Visual Studio 2019. The errors are:
a.      System.Windows.Data Error: 1 : Cannot create default converter to perform 'one-way' conversions between types 'System.Windows.Media.AlignmentY' and 'System.Windows.VerticalAlignment'. Consider using Converter property of Binding. BindingExpression:Path=TextVerticalAlignment; DataItem='EntityNode' (Name=''); target element is 'TextBlock' (Name=''); target property is 'VerticalAlignment' (type 'VerticalAlignment')
b.      System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='Top' BindingExpression:Path=TextVerticalAlignment; DataItem='EntityNode' (Name=''); target element is 'TextBlock' (Name=''); target property is 'VerticalAlignment' (type 'VerticalAlignment')

3.      I have created a custom DiagramLink with a custom property. I want to set the StrokeDashStyle based on the value of the custom property. However, when I add a DataTrigger for the StrokeDashStyle property, I get an error “The property StrokeDashStyle is not a DependancyProperty…” This seems odd as I can set other properties such as Brush, StrokeThickness, etc. Am I missing something here? What would be the correct way to set the style based on the value of a property?

4.      I also want to set the HeadShape and BaseShape of the DiagramLink to be custom shapes I have defined in the project. As these are in a custom class, I am not seeing how I can assign these through a xaml DataTrigger. Any help here is appreciated.
  

ModifiedTutorial4_CS.zip ( 41 KB | 222 Downloads )
Test123.zip ( 21 KB | 135 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Multiple Questions on Diagram Styling
Reply #1 - Feb 19th, 2021 at 10:43am
Print Post  
Quote:
1. Styling for a Table Node: Can a table node be styled so that when a mouse rolls over a row, the entire row background color can be changed. This would be similar to a DataGrid.RowStyle where a Style Trigger can be assigned to change the entire row style. I see where it can be assigned to a Table Node Cell but I’d like it for the entire row.


If you enable Diagram.AutoHighlightRows the diagram will highlight rows when clicked, but not when hovered. You can implement latter like this -

Code
Select All
diagram.RowHighlightBrush = new SolidColorBrush(Colors.Red);
diagram.MouseMove += OnDiagramMouseMove;

void OnDiagramMouseMove(object sender, MouseEventArgs e)
{
	var diagramPoint = e.GetPosition(diagram.DocumentPlane);
	var table = diagram.GetNodeAt(diagramPoint) as TableNode;
	if (table != null)
	{
		int row = -1;
		int col = -1;
		if (table.CellFromPoint(diagramPoint, true, ref row, ref col))
			table.HighlightedRow = row;
	}
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Multiple Questions on Diagram Styling
Reply #2 - Feb 19th, 2021 at 11:17am
Print Post  
Quote:
The only difference I can find is in the namespaces.


WPF loads styles from generic.xaml (as in tutorial) automatically, while you need to load Style.xaml from your second project explicitly. E.g. adding this to MainWindow shows the node correctly -

Code
Select All
<Window.Resources>
	<ResourceDictionary Source="Style.xaml"/>
</Window.Resources>
 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Multiple Questions on Diagram Styling
Reply #3 - Feb 19th, 2021 at 11:37am
Print Post  
Quote:
I have created a custom DiagramLink with a custom property. I want to set the StrokeDashStyle based on the value of the custom property...


StrokeDashStyleProperty is created by calling AddOwner on Pen.DashStyleProperty. Does it work if you use just "DashStyle" in DataTrigger?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Multiple Questions on Diagram Styling
Reply #4 - Feb 19th, 2021 at 12:01pm
Print Post  
Quote:
I also want to set the HeadShape and BaseShape of the DiagramLink to be custom shapes I have defined in the project. As these are in a custom class, I am not seeing how I can assign these through a xaml DataTrigger. Any help here is appreciated.


Pass a string id to your custom Shape definitions' constructor. Then you'd be able to just specify that id value in trigger's setter (built-in ShapeConverter calls Shape.FromId for string values).

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint