Converters to and from #10146
sonicsmooth
started this conversation in
General
Replies: 1 comment 1 reply
-
In a TemplatedControl, I probably would calculate the other value in code behind. You can check out |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a few questions about converters, in this case user string --> value --> formatted string
I have a user-typed text field which should be converted from a string with possible engineering notation, to an internal numerical value.
I also need to convert that internal numerical value to a properly formatted string in the UI TextBlock.
IValueConverter.Convert
) is from Avalonia Property to UI, and thatIValueConverter.ConvertBack
is the opposite, but I'm not sure whetherConvertBack
is used only in error cases or normal. It seemed to be called at startup when the user textbox was being automatically populated, and this happened even withOneWayToSource
.Mode=OneWayToSource
orTwoWay
didn't help matters.null
,new BindingNotification(new InvalidCastException(), BindingErrorType.Error)
, and throwingnew NotSupportedException()
, but these did not result in the red mark showing up in the UI.Distance
, with a question markDistance?
so it can be null if the conversion fails, but that didn't work.TemplatedControl
and all the properties are defined in codebehind, not viewmodel, if that makes any difference.Beta Was this translation helpful? Give feedback.
All reactions