Hi,
I have a XamDataGrid with many Fields that share different styles.
Now each field needs it's MaxLength set individually.
I tried to achieve that by making an attached dependebcyproperty but I have problems accessing ValueConstraint.MaxLength.
This is what I have so far:
using System.Globalization;using System.Windows;using Infragistics.Windows.DataPresenter;using Infragistics.Windows.Editors;
namespace MyNamespace{ public static class MaxLengthHelper {
public static readonly DependencyProperty MaxLengthProperty = DependencyProperty.RegisterAttached(
"MaxLengthHelper",typeof(string), typeof(MaxLengthHelper), new FrameworkPropertyMetadata(null, MaxLengthChanged));
private static void MaxLengthChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { Field field = obj as Field; if (field != null) { ValueConstraint vc = new ValueConstraint(); if(e.OldValue != null) vc.MaxLength = (int)e.OldValue;
//Set the field'S MaxLength here } } }}
Hello Jan-Oliver,
Thank you for your post.
I have been looking into it and what I can suggest is to create styles for each value editor. You can take a look at the following forum thread, where the similar functionality was achieved:
http://ko.infragistics.com/community/forums/t/31984.aspx
I created short sample application based on your scenario to show you how you can implement the functionality that you are looking for. Basically in the sample I created two styles for XamTextEditor and XamNumericEditor. In the styles I created a setter for the ValueConstraint property and set some constraint. Than by using EditorStyle property of the Field class I applied these styles.
Please let me know if you require any further assistance on the matter.
Hi Zhivko,
my fields share already pretty complex editorstyles but need their maxlength set differently. I think this is not possible with your solution, please correct me if I'm wrong.
Therefore, I'm trying to make an attached property / set the length programatically.
Best
Oliver
Thank you for your feedback.
I have been investigating further your issue and I created short sample application in order to be able to show you how you can implement the functionality that you are looking for. Basically in the sample application I crated attached property that set MaxLength property of ValueConstraint in Field.
Please let me know if you need any further assistance on the matter.
that's exactly what I was looking for. Unfortunately I'm using Infragistics Version 14.1 where field.ValueConstraint cannot be resolved.
The ValueConstraint seems to be hidden somewhere in Field.settings.editorstyle....
Would you mind, modifying your example for Version 14.1?
I have been looking into your issue. Currently you have a trial account. The support provided for trial accounts is for the latest version of our controls only. Currently this version is 15.1. More information about this you can find on the following link from our documentation:
http://ko.infragistics.com/support/support-policies.
If you would like to receive support for version 14.1 of our controls I could suggest contacting our Sales Department. The contacts for the Sales Department you can find on the following link from our web site:
http://ko.infragistics.com/about-us/contact-us.
Please do not hesitate to let me know if you have any further questions on this matter.
my account information should now be displayed correctly. I'm still interested in the solution for 14.1.
I have been investigating your requirement. It seems that currently in order to be able to achieve the functionality that you are looking for with version 14.1 you have to create style for value editor(XamTextEditor, XamNumericEditor ,….).
I am not sure what are your styles and your own TextBoxField and TextBoxFieldSetting that you are using . It will be great if could modify my sample application with styles and functionality that you are using, so I will be able to further investigate your issue.
Hello,
I am just checking if there is anything else I can do for you.
I have been looking into it. It seems that currently with version 14.1 in order to be able to set MaxLength as you want – individual for each field, you should create style for the editor and set MaxLength property to its Value Constraint.
does this mean, I would have to create a style for each of my columns?
You can find my TextboxField and TextboxFieldSettings above in one of my posts.
Modifying your example to work is quite challenging because my project is very big and complex (e.g. Unity pattern).