Int64EditBox: '1000000' is not a valid value for property 'StepValue'

Editors for WPF Forum

Posted 5 years ago by Markus Springweiler
Version: 14.2.0610
Platform: .NET 4.5
Environment: Windows 8 (64-bit)
Avatar

StepValue is defined as Int32, so 1000000 should not be a problem.

I first only noticed this problem in Visual Studios XAML designer, but at runtime (running at German locale) there were no problems. But changing the locale to "English" I now get a runtime exception which kills my app immediately, although we are handling nearly every unhandled exception with an error-report dialog:

 

System.Windows.Markup.XamlParseException occurred
  HResult=-2146233087
  Message='Set property 'ActiproSoftware.Windows.Controls.Editors.Parts.Primitives.Int64PartBase(System.Nullable(System.Int64)).StepValue' threw an exception.' Line number '58' and line position '8'.
  Source=PresentationFramework
  LineNumber=58
  LinePosition=8
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at DotNetFabrik.DoublePics.Cockpit.MainWindowParts.PartMainParts.PartSearchPreparationParts.FileHashSearchPreparation.InitializeComponent()
       at DotNetFabrik.DoublePics.Cockpit.MainWindowParts.PartMainParts.PartSearchPreparationParts.FileHashSearchPreparation..ctor()
  InnerException: System.ArgumentException
       HResult=-2147024809
       Message='1000000' is not a valid value for property 'StepValue'.
       Source=WindowsBase
       StackTrace:
            at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
            at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
       InnerException: 

Comments (6)

Posted 5 years ago by Markus Springweiler
Avatar

I btw found no single number I can enter here which gets accepted. Even <editors:Int64EditBox StepValue="1" /> does not work. Not even when using a clearly typed static resource: <System:Int32 x:Key="FileSizeStepValue">100000</System:Int32> -- whats going on here?

 

I even cannot assign it by code (this way it also fails on German locale):

private void FileSizeInt64EditBoxLoaded(object sender, RoutedEventArgs e)
{
  var box = (Int64EditBox)sender;
  box.StepValue = 1000000;
}

[Modified 5 years ago]

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Markus,

That appears to be a problem with the VS designer converting your Int32 value to an Int64.  StepValue on the Int64EditBox is an Int64, not an Int32.  The good news is that you can get it working if you specify it like this:

<editors:Int64EditBox>
	<editors:Int64EditBox.StepValue>
		<system:Int64>100000</system:Int64>
	</editors:Int64EditBox.StepValue>
</editors:Int64EditBox>


Actipro Software Support

Posted 5 years ago by Markus Springweiler
Avatar

This doesn't explain why the C# code compiles but also fails at runtime. (Or does it?)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Either way, the problem is with Microsoft's .NET or VS code converting the number to an Int64 in its XAML deserializer.  If you specify the exact type per above, it will work around the problem.  This doesn't happen with Int32EditBox since that uses an Int32-based step value and the XAML deserializer knows how to handle those fine.


Actipro Software Support

Answer - Posted 5 years ago by Markus Springweiler
Avatar

I would say the "problem" of the VS designer is your mismatch of the DependencyProperty (Int64) and your CLR property (Int32):

 

class Int64EditBoxBase
{
    public int StepValue
    {
      get
      {
        return (int) this.GetValue(Int64EditBoxBase.StepValueProperty);
      }
      set
      {
        this.SetValue(Int64EditBoxBase.StepValueProperty, (object) value);
      }
    }
}

 

So this is a bug which can be fixed on your side.

[Modified 5 years ago]

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Markus,

Sorry, I missed seeing that it was accidentally set as an int return on the public property.  That is indeed the issue and changing it to Int64 to match the dependency property declaration seems to fix the problem.  This will be in the next build.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.