Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 333 characters in body
Source Link
user2819245
user2819245

The validation as depicted above will just show a slim red rectangle around a text box if the ValidationRule fails (this is default behavior for a text box). If your UI should present a more elaborate validation error response, most certainly you will need to do much more than just only adding the ValidationRule to the bindings...

The validation as depicted above will just show a slim red rectangle around a text box if the ValidationRule fails (this is default behavior for a text box). If your UI should present a more elaborate validation error response, most certainly you will need to do much more than just only adding the ValidationRule to the bindings...

added 60 characters in body
Source Link
user2819245
user2819245
  • The bindings of each text box belonging to the same serial number need to use the same converter instance (so that the _serialNumberParts array will be able to keep track of the complete serial number)

  • If the UI provides several text box groups for entering multiple serial numbers, then each of these text box groups need to use a separate converter instance (otherwise, serial number parts of different serial numbers could mix in the same _serialNumberParts array). In my XAML example above, i ensured this by placing the converter instance in the resource dictionary of the parent StackPanel of the text boxes (which makes the converter instance local to this StackPanel and its descendent elements).

  • It is required to use data bindings for all serial number parts. Otherwise, the _serialNumberParts array will never be populated fully, which in turn will prevent ConvertBack from returning any complete serial number.

  • The bindings of each text box belonging to the same serial number need to use the same converter instance (so that the _serialNumberParts array will be able to keep track of the complete serial number)

  • If the UI provides several text box groups for entering multiple serial numbers, then each of these text box groups need to use a separate converter instance (otherwise, serial number parts of different serial numbers could mix in the same _serialNumberParts array). In my XAML example above, i ensured this by placing the converter instance in the resource dictionary of the parent StackPanel of the text boxes (which makes the converter instance local to this StackPanel).

  • It is required to use data bindings for all serial number parts. Otherwise, the _serialNumberParts array will never be populated fully, which in turn will prevent ConvertBack from returning any complete serial number.

  • The bindings of each text box belonging to the same serial number need to use the same converter instance (so that the _serialNumberParts array will be able to keep track of the complete serial number)

  • If the UI provides several text box groups for entering multiple serial numbers, then each of these text box groups need to use a separate converter instance (otherwise, serial number parts of different serial numbers could mix in the same _serialNumberParts array). In my XAML example above, i ensured this by placing the converter instance in the resource dictionary of the parent StackPanel of the text boxes (which makes the converter instance local to this StackPanel and its descendent elements).

  • It is required to use data bindings for all serial number parts. Otherwise, the _serialNumberParts array will never be populated fully, which in turn will prevent ConvertBack from returning any complete serial number.

added 60 characters in body
Source Link
user2819245
user2819245

In this situation, a custom IValueConverter is being usedcan provide the required functionality. Let's call this custom converter SerialNumberConverterSerialNumberConverter. 

As already hinted at by IL_Agent's very brief answer, you would use the converter in XAML likesimliar to the following:

In this situation, a custom IValueConverter is being used. Let's call this converter SerialNumberConverter. As already hinted at by IL_Agent's very brief answer, you would use the converter in XAML like:

In this situation, a custom IValueConverter can provide the required functionality. Let's call this custom converter SerialNumberConverter. 

As already hinted at by IL_Agent's very brief answer, you would use the converter in XAML simliar to the following:

added 239 characters in body
Source Link
user2819245
user2819245
Loading
added 239 characters in body
Source Link
user2819245
user2819245
Loading
added 239 characters in body
Source Link
user2819245
user2819245
Loading
added 239 characters in body
Source Link
user2819245
user2819245
Loading
Source Link
user2819245
user2819245
Loading