DisplayFormat Attribute

Grids for WPF Forum

The latest build of this product (v21.1.1) was released 1 month ago, which was before this thread was created.
Posted 28 days ago by Patrick Milinazzo - Woodward, Inc.
Version: 20.1.1
Avatar

Is the DisplayFormat attribute supported. It doesn't seem to be and I'm wondering if there is a way to format the property values using the built-in expandable property editor.

public struct SerializableBounds {
		public SerializableBounds(double x, double y, double width, double height) {
			Location = new SerializablePoint(x, y);
			Size = new SerializableSize(width, height);
		}


		public SerializableBounds(SerializablePoint location, SerializableSize size) {
			Location = location;
			Size = size;
		}


		public SerializablePoint Location;
		public SerializableSize Size;

		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:N0}")]
		[NotifyParentProperty(true)]
		public double Width {
			get =>
				Size.Width;
			set =>
				Size.Width = value;
		}

		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:N0}")]
		[NotifyParentProperty(true)]
		public double Height {
			get =>
				Size.Height;
			set =>
				Size.Height = value;
		}

		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:N0}")]
		[NotifyParentProperty(true)]
		public double X {
			get =>
				Location.X;
			set =>
				Location.X = value;
		}

		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:N0}")]
		[NotifyParentProperty(true)]
		public double Y {
			get =>
				Location.Y;
			set =>
				Location.Y = value;
		}
}

Comments (3)

Posted 27 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Patrick,

I'm sorry but DisplayFormatAttribute isn't supported at this time.  I will log your request for that feature.

In the meantime, you can use property editors to specify a format.  There are extensive docs on how to target properties with property editors.  You can specify the format to use with our edit boxes there.

<grids:PropertyGrid.PropertyEditors>
  <gridseditors:DoublePropertyEditor PropertyName="Width" Format="N0" />
</grids:PropertyGrid.PropertyEditors>


Actipro Software Support

Posted 26 days ago by Patrick Milinazzo - Woodward, Inc.
Avatar

Looks like the DoublePropertyEditor is in the Interop.Editors nuget, which relies on the Editors nuget, which we did not purchase.

I guess I will have to create a custom editor

Posted 26 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Patrick,

Correct, the DoublePropertyEditor is a property editor that uses Editors' DoubleEditBox control.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.