Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Validating data in Mindfusion Diagrams (Read 1957 times)
samrat.ghose
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Nov 19th, 2009
Validating data in Mindfusion Diagrams
Nov 19th, 2009 at 12:02pm
Print Post  
Hi,
  We are using MindFusion WPF diagram to create forms with controls such as textbox , combobox etc in them. We are setting the minlength and maxlength for the controls say a textbox. Now when the user inputs data how do we vaidate the data the user has entered for minlength , maxlength.

Does mindfusion provide any programmatic APIs for data validation?

Thanx in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Validating data in Mindfusion Diagrams
Reply #1 - Nov 19th, 2009 at 12:31pm
Print Post  
Hi,

The control does not provide any built-in validation. If you have some WPF bindings attached to the hosted controls, you could add ValidationRules to these bindings and display validation errors using the System.Windows.Controls.Validation class.

Stoyan
  
Back to top
 
IP Logged
 
samrat.ghose
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Nov 19th, 2009
Re: Validating data in Mindfusion Diagrams
Reply #2 - Nov 19th, 2009 at 12:37pm
Print Post  
Hi ,
Thanks for the reply. We are saving the mindfusion diagram as xml and then using the following API of midfusion diagram

WpfDiagram.LoadFromString(this.FormXml);

to generate the screen . 'FormXml' contains all the controls and values along with atributes such as 'minmaxlength' .

Is there a way to validate the data entered in these controls against the stored validation attributes.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Validating data in Mindfusion Diagrams
Reply #3 - Nov 19th, 2009 at 12:55pm
Print Post  
Hi,

After loading, you could loop over all nodes and add some bindings to their hosted controls:

Code
Select All
TextBox textBox = (node as DiagramNodeAdapter).UIElement as TextBox;
if (textBox != null)
{
	Binding binding = new Binding("Value");
	// assuming Tag objects have a Value property
	binding.Source = node.Tag;
	// todo: add validation rules here
	textBox.SetBinding(TextBox.TextProperty, binding);
}
 



This MSDN topic shows how to create a min/max rule, which you can add to the ValidationRules collection of the "binding" object.

http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validationru...

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint