I have this property bound twoway to the text property of the Numeric Input, where maxQuantity is a value i set somewhere else. I dont want the user to be able to input anything above that maxQuantity value. I found when the user is typing the value in, the property is getting set correctly but it isnt actually changing the textbox and this only happens while the cursor is on the textbox. if i attempt to update this property without the cursor being on the textbox (through some other event) it updates fine. theres only an issue when the cursor is there. any ideas?
public int TransferQuantity { get { return this.TransferQuantity; } set { if (this.TransferQuantity != value) {
if (value <= MaxQuantity && value >= 0) { this.TransferQuantity = value; } else if (value > MaxQuantity) { this.TransferQuantity = MaxQuantity; } else { this.TransferQuantity = 0;
} } OnPropertyChanged("TransferQuantity"); } }
Hello,
Thank you for your post. I have been looking into it and I can suggest you use the XamNumericinput’s ValueConstraint Property instead of checking the value in the Setter of your Property. You can set the Constraints like this:
<ig:XamNumericInput Name="xamNumericInput1" > <ig:XamNumericInput.ValueConstraint> <ig:ValueConstraint MaxInclusive="10" MinInclusive="0"/> </ig:XamNumericInput.ValueConstraint> </ig:XamNumericInput>
This way the user won’t be able to enter values less than 0 and greater than 10. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Few issues.
I'm using the numeric Input control inside a user control and it seems to change its entire layout (could be an issue)
I dont need a pop up telling the user they cant set the value and after the window closes the value they inputed still remains.
I'm using this outside of a grid, the user selects a grid and then based on a value inside the grid, the user cannot input a number higher then this set paramater. If they input a value higher then the given 'maxQuantity' then i want the numericinput to be set to that value. I've tried putting two controls text bound to the same property to see their results. It seems it works as long as the focus isn't on the control itself, if i type in control 1 a value higher then the max, control 2 automatically sets it back to the max but this isnt the case for the first control.
Hello Adam,
I have tested your behavior with the MS TextBox and the result was the same and since we use it in the XamNumericEditor I can suggest you ask in the MS forums, where you can get a reply by an WPF expert, becasue your issue seems to be connected with the WPF Binding mechanism.
Hope this helps you.
I'm having somewhat the same issue. Ibound the XamNumericInupt text to a property and set a MaxExclusive value and it works. Since MaxExculsive expects an object I bound it to an object property however I get the following output error:
Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=MaxNumber; DataItem=null; target element is 'ValueConstraint' (HashCode=12176960); target property is 'MaxExclusive' (type 'Object')
I'm assuming I may need a converter to convert integer to ValuceConstraint but how would I go about that process?
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.