I have two DecimalUpDown Controls in my Window. One should show the maximum Value the other one minimum Value of the TextBox. The minimum control can not have greater values than the maximum one and vice versa.
Notice that the red values are wrong one.
How can I implement this? I am using the MVVM pattern.
Thank you. Steve
You should implement the validation logic in your view model:
XAML:
Please refer to the following blog post for more information about how data validation in WPF works: https://blog.magnusmontin.net/2013/08/26/data-validation-in-wpf/.
You basiclly implement either the
IDataErrorInfo
or the newerINotifyDataErrorInfo
in your view model.You can use onChange event from the text box . (select your textBox and check the event window you will find all events)
Wen change => compare value if error => show message
as I understand you need to compare max and min values in setters of your VM properties