Question

PropertyGrid.PropertyEditors

Posted 29 days ago by Avatar Neil Larson

Having trouble using the Actipro TimeSpanEditBox as a propertyEditor.

 

The editor is displayed with the correct format, but the value is always 0:00:00:00. 

Im sure its something obvious but I cant spot it. If I remove the editor template, it all works correctly using the default editor.

I followed one of the examples to get this far, heres the code.

<propgrid:PropertyGrid.PropertyEditors>
   <propgrid:PropertyEditor PropertyName="TimeFromShowStart">
      <propgrid:PropertyEditor.ValueTemplate>
         <DataTemplate>
            <editors:TimeSpanEditBox Format="h:mm:ss.ff" />
         </DataTemplate>
      </propgrid:PropertyEditor.ValueTemplate>
   </propgrid:PropertyEditor>
</propgrid:PropertyGrid.PropertyEditors>

 

      private TimeSpan _TimeFromShowStart;
      [DisplayName("Time From Start")]
      [Category("Timing")]
      [Description("Time from the start of the show this command executes. Timing accurate to 1/100th of a second. Format HH:MM:SS.SS")]
      //[TypeConverter(typeof(TimeSpanFormatConverter))]
      //[Editor(typeof(StringPropertyEditor), typeof(PropertyEditor))]
      [Browsable(true)]
      public TimeSpan TimeFromShowStart
      {
         get { return _TimeFromShowStart; }
         set
         {
            if (_TimeFromShowStart == value)
               return;

            DefaultChangeFactory.Current.OnChanging(this, nameof(TimeFromShowStart), _TimeFromShowStart, value, "TimeFromShowStart Changed");
            var oldval = _TimeFromShowStart;
            _TimeFromShowStart = value;
            RaisePropertyChanged(() => TimeFromShowStart, oldval, value, true);
         }
      }

 

Btw, the search on the web page for the forums always returns 0 results.


Comments (2)

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

Hi Neil,

There are a lot of properties that can be bound onto the edit box, most importantly the Value.  I think that's what you're missing here. 

This is our default template:

<DataTemplate x:Key="TimeSpanValueTemplate">
	<editors:TimeSpanEditBox Value="{Binding Value, Mode=TwoWay}" 
		BorderThickness="0" IsReadOnly="{Binding IsReadOnly}" 
							   
		CommitTriggers="{Binding ValuePropertyEditor.CommitTriggers}"
		HasPopup="{Binding ValuePropertyEditor.HasPopup}"
		IsArrowKeyPartNavigationEnabled="{Binding ValuePropertyEditor.IsArrowKeyPartNavigationEnabled}"
		IsEditable="{Binding ValuePropertyEditor.IsEditable}"
		IsNullAllowed="{Binding ValuePropertyEditor.IsNullAllowed}"
		PlaceholderText="{Binding ValuePropertyEditor.PlaceholderText}"
		SpinnerVisibility="{Binding ValuePropertyEditor.SpinnerVisibility}"
		SpinWrapping="{Binding ValuePropertyEditor.SpinWrapping}"
		TextAlignment="{Binding ValuePropertyEditor.TextAlignment}"
							   
		DefaultValue="{Binding ValuePropertyEditor.DefaultValue}"
		Format="{Binding ValuePropertyEditor.Format}"
		LargeChange="{Binding ValuePropertyEditor.LargeChange}"
		Maximum="{Binding ValuePropertyEditor.Maximum}"
		Minimum="{Binding ValuePropertyEditor.Minimum}"
		SmallChange="{Binding ValuePropertyEditor.SmallChange}"
		/>
</DataTemplate>

Instead of what you're doing though, you might just want to create an instance of TimeSpanPropertyEditor for that PropertyName so the default template is used.  Then just set its Format property and that will get used by the default template.


Actipro Software Support
Posted 28 days ago by Neil Larson

Argh.... Value="{Binding Path=Value, Mode=TwoWay}"  I wonder why I didn't see it in the sample code. Late night coding sleepy strikes again.

 

Thanks! 

Information The latest build of this product (2018.1 build 0673) was released 7 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.