DisplayFormat Attribute

Grids for WPF Forum

Posted 3 years 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 3 years 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 3 years 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 3 years 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

The latest build of this product (v24.1.2) was released 25 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.