First of all such questions are irrelevant to XAML. I mean, all you can do in XAML you can do without XAML. In fact, XAML (in their use for windows, custom controls and the like) is fully eliminated by the build, which does the following: translate XAML in C# (in your case) code and builds the assembly with that code exactly as with any other code.
So, my first and main advice
: if you want to know how to do something without XAML but only know how to do it with XAML, actually write XAML you want and build the project. Then find the auto-generated C# code (under your project's "obj" sub-directory) and see how it works.
Now, you pointed out yourself that if you have an instance of some shape, you can get an instance of
"by RenderedGeometry". It really means that you can use the property
As the word "Polyline" can be understood as the
, you can use this property for this class, too. I don't understand how it could be a problem. Or I don't understand why could you consider it a "work-around". It's probably the simplest way. Perhaps you don't want to have any shape because it's irrelevant to your solution; so I can understand it.
Then the second simplest way would be creating and instance of
from scratch, using the class
, which is the class derived from
. If you need only one polyline, use only one
member, say, throw the constructors
You can just pass a one-element array with an instance of
. In turn, such instance can be constructed from a collection of the elements of the class
In turn, for concrete kinds of type segments, you need to use the class derived from
. For just a polyline, it can be a collection of segments of the type
, or, alternatively, the whole polyline in one segment with the class
Assemble it together and you will get an instance of
. Also note that you can use the class
to combine different types of geometry in one.