In Make conversion code reusable in Xamarin.Forms I expain how to convert an SVG path (stored in a resource file in this case) to the
Data property of a
Now I want to be able to use the
IValueConverter to convert a value even if it is not a property on the viewmodel. In this example the value is an SVG path stored as a string in a resource file.
The fundamental requirement still remains that
Data is of type
Geometry and requires a convertion from
Geometry to be able to use a resource value stored as string.
results in a type mismatch error and does not even compile.
The solution is to expand the
IValueConverter and add a
property that will be used as the source if it has been set.
Here’s how to do it:
Add a property to the value converter
Then adapt the
Use Binding markup to set
IValueConverter and the
example of SVG string data rendered in a Path
- Previous post: Make conversion code reusable in Xamarin.Forms