Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) WPF examples (Read 11742 times)
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
WPF examples
Aug 3rd, 2011 at 2:04pm
Print Post  
Hi

In all the examples I have, nodes are created by c# code or with an XML file.

Is there example where the nodes and theirs contents are created in WPF code?

I would really appreciate to see some complex nodes and links in WPF. For now I create nodes and contents from code behind, but it is fastidious.

Thanks for your help

Richard
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF examples
Reply #1 - Aug 3rd, 2011 at 3:11pm
Print Post  
Quote:
Is there example where the nodes and theirs contents are created in WPF code?

If by "WPF code" you mean XAML, then no, diagrams elements cannot be declared in XAML. However, I will check if I can work around this limitation and come back to you when I have a solution.

Regards,
Meppy
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #2 - Aug 3rd, 2011 at 3:20pm
Print Post  
Well, it would be great, thank you Smiley .
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #3 - Aug 3rd, 2011 at 3:41pm
Print Post  
In fact you have a great product. Now, maybe I am wrong, but I think it is a lack that we can't use it with XAML.

XAML is easy to use, and designer can use it without knowing too much about code behind. It would be great to use your product and keep the benefices of XAML.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF examples
Reply #4 - Aug 4th, 2011 at 2:14pm
Print Post  
Try this version:

https://mindfusion.eu/download/WpfDiagram.trial.zip

You can now define nodes and links in XAML. However, there are various limitations, such as not being able to bind any non-dependency properties. In addition, the designer does not always repaint properly in response to changes to the nodes and links. You will have to rebuild your project (or close and reopen the window) in order to view the changes.

Here is an example code, which creates two nodes and connects them with a link:

Code
Select All
<d:Diagram Name="diagram">
      <d:Diagram.Nodes>
            <d:ShapeNode x:Name="n1" Bounds="30,30,20,20" Brush="Red" />
            <d:ShapeNode x:Name="n2" Bounds="150,110,20,20" Brush="Yellow" Shape="Ellipse" />
      </d:Diagram.Nodes>
      <d:Diagram.Links>
            <d:DiagramLink d:LinkTo.OriginNode="n1" d:LinkTo.DestinationNode="n2" HeadShapeSize="10" />
      </d:Diagram.Links>
</d:Diagram> 


Note how the origin and destination nodes of the link are specified.

Let me know what you think.

Regards,
Meppy
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #5 - Aug 4th, 2011 at 3:52pm
Print Post  
It seems to work!
Thanks a lot!

Could you please provide an example of databing a tablenode with a xml file?

And how to put a shapenode in a cell of tablenode, in XAML?

And if I want to modify some properties in the codebehind, for the node, before the user begins to interact with the UI, where is the best place (event) to that?
I tried to change the caption of a tablenode (created in XAML) in the OnWindowLoaded event, but it does not work.

Thank you very much
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF examples
Reply #6 - Aug 5th, 2011 at 6:32am
Print Post  
Quote:
Could you please provide an example of databing a tablenode with a xml file?

Very few properties of the diagram items are currently dependency properties. You can bind only those properties. Bounds, EnabledHandles, RotationAngle and Text come to mind. In order to bind those properties use the standard {Binding} markup extension. Finally, supply the data source - one way to do this is through the Diagram.DataContext property.

Quote:
And how to put a shapenode in a cell of tablenode, in XAML?

You can't do this, neither programmatically nor through XAML. You can position the node on top of a table cell, then lock it and group it with the table so that when the table is moved the node is moved along, thus giving the impression that the node is inside the cell.

Quote:
And if I want to modify some properties in the codebehind, for the node, before the user begins to interact with the UI, where is the best place (event) to that?

You can do it in the window's constructor after the call to InitializeComponent.

Regards,
Meppy
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #7 - Aug 5th, 2011 at 9:55am
Print Post  
Thanks for your answer, Meppy!

When you say:

Quote:
Very few properties of the diagram items are currently dependency properties. You can bind only those properties. Bounds, EnabledHandles, RotationAngle and Text come to mind. In order to bind those properties use the standard {Binding} markup extension. Finally, supply the data source - one way to do this is through the Diagram.DataContext property.


I am a little confused. Lets say I have 2 tableNodes on my diagram, one for customers and one for products. I have files Customer.xlm and Products.xml. How to populate the tablenodes customers and products?

I did not find, in the TableNode properties, a property that I could use a source.

Thanks for your help.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF examples
Reply #8 - Aug 5th, 2011 at 10:13am
Print Post  
Currently you cannot populate TableNode using binding, this can be done only in code. The text of each cell can be specified through the Text property of the cell. Cells can be accessed using indexing on the TableNode:

Code
Select All
table[0, 0].Text = "First cell"; 


Regards,
Meppy
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #9 - Aug 5th, 2011 at 10:36am
Print Post  
Ok, thank you for your answer, and sorry to have so many questions Wink .

So, if I want to populate a tablenode in the codebehind, how I do that? Is there a kind of "ItemsSource" property, like in a listView?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF examples
Reply #10 - Aug 5th, 2011 at 10:47am
Print Post  
You need to assign the text of each cell in the table manually - by setting the Text property of the cell as illustrated in my previous post. So if you have an XML with the data and you need to populate a table node with this data, you have to read the XML manually (with LINQ-to-XML or an XML reader) and then assign the read data to the cells in the TableNode.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #11 - Aug 5th, 2011 at 11:01am
Print Post  
No true databing and no possible use of data templates, then, if I understand correctly. That is a problem for our application.


Is that a possible evolution for you product? A databing for tablesNode would be great.

  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: WPF examples
Reply #12 - Aug 5th, 2011 at 12:12pm
Print Post  
This is something we may consider but it won't happen in the immediate future since it will require a substantial rework of the existing implementation.

On a side note, you can try implementing databinding yourself, by subclassing from TableNode and providing a dependency property for a DataSource. The implementation of this property will internally carry out all of the table population from the supplied data. Then, you can bind this property to your data from within XAML.

Regards,
Meppy
  
Back to top
 
IP Logged
 
RichardW2C
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Jul 13th, 2011
Re: WPF examples
Reply #13 - Aug 5th, 2011 at 12:35pm
Print Post  
Ok, that could be a way. Thank you for yours answers Smiley !
  
Back to top
 
IP Logged
 
jackalexander
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Sep 24th, 2011
Re: WPF examples
Reply #14 - Nov 9th, 2011 at 1:02pm
Print Post  
I think that means that you cannot bind to say Diagram.Nodes in Xaml.  If this is so, then in a normal app you need to build a list of nodes from your business objects add the nodes to the Diagram, in code.   

What would be the normal way that you would see the UI responding to changes in the business objects then?  For eg. if the user adds a node, should we respond to the event for this from the diagram and add that to the business objects? 

Hope this question makes sense.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint