I'm starting to think that I'm writing strange programs, because what I do and I consider very simple in MVVM context does not work as I expect.
I suppose I'm doing things wrong and I hope you can enlight me.
I have a Window, that edits a Class with 2 properties Name, Weight, Name is a string so I use a Textbox editor and works perfectly Weight is an integer so I've set a XamNumericInput editor the code for the two controls is as follows:
<TextBox Grid.Row="0" Grid.Column="1" Margin="4,20,4,20" HorizontalAlignment="Stretch"VerticalAlignment="Stretch" Text="{Binding Path=Item.Name, Mode=TwoWay}" />
<ig:XamNumericInput Grid.Row="1" Grid.Column="1" Margin="4,20,4,20" HorizontalAlignment="Stretch" VerticalAlignment="Center" Value="{Binding Path=Item.Weight, Mode=TwoWay}" Mask="nnnnnn" InvalidValueBehavior="DisplayErrorMessage"/>
Now while the Textbox works perfectly and is set with the value when I initialize the Item Property and Updates its value when the Text is changed
The XamNumericInput unfortunately displays the right value so I presume the binding is at last working one way but it does not change the value property when edited I've tried also not using a Mask and the control puts a non integer
In all the samples you made in your sample browser the only bindings made on XamNumericInput are made on properties that are of no use (Mask or other settings nice to know I can bind them but maybe something more regarding Value binding?)
The Only sample with a binding to the value, binds a textblock to the value using the elementname inside xaml, no samples with a viewmodel...
can you tell me what do I have to do to use a bound property to this editor
thank you in advance
regards
Sabrina
Hi Sabrina,
I'm glad the converter is working for you. I'm not really sure if this is due to the XamNumericInput itself. The error I see mentions the use of Int32Converter which is a .NET object. And according to documentation, this converter can only convert a 32-bit signed integer object to and from a string. I tried checking the source code for the xamInput controls where Int32Converter might be used but I can't find it anywhere. This leads me to believe that .NET is trying to do the conversion rather than our control. I can't really be sure though.
I didn't expect the control to be so "severe" :D:D:D I've created an Int To Double converter and set it on the binding and it works correctly.
Thank you
The default type the XamNumericInput expects is a double but the property you have it bound to is an integer. You should see some errors in the output window about trying to cast an integer into a double and vice versa. Set the ValueTypeName property to "Int32" and this should resolve the issue.