Relative Content

Tag Archive for c#wpf.net-6.0avaloniastaticresource

How to use the content of Icon Resource in code-behind mode situation in Avalonia framework

Backgorud:
We can usually use content of Icon Resource by AXAML in Avalonia framework such as this example
,the mail_copy_regular is an object which is a StreamGeometry type and the icon resources provided by avalonia whose url is https://avaloniaui.github.io/icons.html.
Problem:
Now I want to try to use content of Icon Resource in code-behind mode situation but I don’t know how to do it.The reason for doing this is that I create the MenuItem object in code-behind mode and assign his property of Icon. The Icon is also an object and can be instantiated by the derived class PathIcon.By reading the official api documentation I found that PathIcon have a Data property which is a StreamGeometry type.So I want to use the official icon resources provided by avalonia to instantiate StreamGeometry.