Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SaveToXml / SaveToString with TemplatedNode (Read 1924 times)
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Location: Seattle
Joined: Feb 6th, 2017
SaveToXml / SaveToString with TemplatedNode
Jun 15th, 2017 at 9:21pm
Print Post  
I have a diagram with TemplatedNodes. Each TemplatedNode can have a different Template assigned so that they show up differently on the diagram.

I've called diagram.SaveToString(SaveToStringFormat.Xml, true) and then later with that string, called diagram.LoadFromString(diagramString)

The correct number of nodes show up and are placed in the correct locations, however they do not seem to have their Template assigned anymore.

How do I get the Template to be saved in the XML string?

Thanks,
Joel.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: SaveToXml / SaveToString with TemplatedNode
Reply #1 - Jun 16th, 2017 at 9:27am
Print Post  
Saving templates is not supported. Consider using style triggers instead -

Code
Select All
<Style TargetType="{x:Type diag:TemplatedNode}">
	<!-- default template -->
	<Setter Property="Template">
		<Setter.Value>
			<DataTemplate DataType="{x:Type diag:TemplatedNode}">
				<Rectangle Fill="Chocolate" />
			</DataTemplate>
		</Setter.Value>
	</Setter>

	<Style.Triggers>
		<!-- template based on tag value -->
		<Trigger Property="Tag" Value="Ellipse">
			<Setter Property="Template">
				<Setter.Value>
					<DataTemplate DataType="{x:Type diag:TemplatedNode}">
						<Ellipse Fill="LightGreen" />
					</DataTemplate>
				</Setter.Value>
			</Setter>
		</Trigger>
	</Style.Triggers>

</Style> 



Now if you use Tag or another property serialized with nodes as a trigger, it should apply the templates also after loading.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Location: Seattle
Joined: Feb 6th, 2017
Re: SaveToXml / SaveToString with TemplatedNode
Reply #2 - Jun 16th, 2017 at 5:31pm
Print Post  
Thanks!  I was already using Tag for something else, but not the Text property.  So assigning that a meaningful string and triggering off it works great.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint