This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi , I have a size requirement for my system that we have to meet. Is there a way for you to make a special build with just the following elements and supporting components? Otherwise we might not be able to use the library.
Also, for PropertyGrid, is there a way to check if any property has an error? For example, user enter an invalid value for property A. I'd like a way to know in code that A is invalid so the system would then prevent the user from continuing. Thanks in advance, Doug |
|
|
Hi Doug, Sorry we do not provide custom built dlls. We do however provide source code that you can purchase at a low cost. With the source code, you can pull out everything that you don't need, and build exactly the dll that you want. If this option could work for you, please email store@mindscape.co.nz The PropertyGrid control does not have events to detect when invalid data has been entered. It does however display a red outline around controls that have invalid data. In the code, you should be able to look at the state of the model that the PropertyGrid is bound to, and determine if the user can continue. -Jason Fauchelle |
|
|
Hi Jason, How would I go about checking from the xaml? I currently have a trigger to the settings properties but that will only give me a list of all the properties. There's another alternative which uses PropertyEditor to limit values. But when doing this I noticed that entering a value thats out of bound will reset it to the max (or min) value and keep the box red. This can be reproduced in the "Styling a built-in editor" example. In age, enter 9999. then click away from the control. It will display 150 and indicate its an error. Doug |
|
|
Hi Doug, To check validation in xaml, you can use the built-in WPF validation system. The PropertyGrid doesn't do anything extra regarding validation. In xaml, you can check the value of the attached Validation.HasError property. You could either use this in a binding, or a style/template trigger. This approach works if exceptions are being thrown in the model as demonstrated in the "Styling a built-in editor" sample. Another way to check in the xaml would be to have a custom editor template. In the template, you can bind to Value which will give you the value being edited. In the "Styling a built-in editor" demo, the exception is being raised in the SimplePerson.Age property before the value is being set. This is why there is still a red border around the control. The value is being limited at 150 by setting the Maximum of the NumericUpDown control. This control still allows all values to pass back to the bound property, but then instantly corrects it back to be within the limit. This type of control behaviour does not work well with throwing exceptions in the property. -Jason Fauchelle |
|
|
Hi Jason, I decided to use the editors but I ran into a question. I need an IntegerUpDownEditoryKey template but there doesn't seem to be one. There is a NumbericUpDownEditorKey but it doesn't seem to work with the ms:IntegerUpDown type. Do you happen to have an alternative or an example of how to to use the IntegerUpDown instead of the NumbericUpDown (float). I thought of another alternative that use IntegerEditorKey and IntegerTextBox but there an is issue with that as well. If there's a min of 5,500 and max of 30,000 (default to 10,000), the user will have to play games to get to 5,500 because the validation is done on key press instead of when the user exits the user control. I am also getting a lot of "System.Windows.Data Error: 4 : Cannot find source for binding with reference ....... VerticalContentAlignment" errors when using Split button. Is this an issue and how do I prevent this from showing up? I also noticed it when running the example program for Split Button. Thanks, Doug |
|
|
Hello Doug To use an IntegerUpDown editor, you'll need to provide a custom editor template rather than using one of the built in templates. This is very simple and can either be done with a PropertyEditor (targets a specific property of a specific type), or a TypeEditor (targets a specific type of property). Here is an example with PropertyEditor based on the "Styling a built-in editor" sample. In this example, the target of the Binding (Value) is a property on the IntegerUpDown, and the source of the Binding (Value) is a property that is available to ALL editor templates which get/sets the property value you are editing.
If you want to use IntegerEditorKey with a minimum greater than 1, I would recommend setting the RangeConstraintMode property of the IntegerTextBox to either OnLostFocus, or OnLosFocusOrReturn. This will cause out of bounds values to enter the model (because the binding is set up to update on property-change rather than lost-focus), but this will allow the user to type whatever they need to get to a valid value, and the the range will be constrained when the editor loses focus. To prevent out of bounds values entering the model, you'd need to use a custom template using the approach above, and set the UpdateSourceTrigger of the Binding to be OnLostFocus. For you last point, this has been around for a while but I've never been able to track it down. I've had another look now, but all our bindings that use VerticalContentAlignment are fine, none of them are being applied to an ItemsControl, and none of them are using AncestorType relative source (These are what I'm seeing in the Error 4 message). This is most likely an issue in a base WPF template. Fortunately this error can be safely ignored, the only downside it has is filling up the console output. -Jason Fauchelle |
|