[AVALONIA] Polylines not displaying on Canvas
I have been having this issue for a while. My Polylines which I have generated are not being displayed in the Canvas.
I am using MVVM so I have created all the Models, ensured they are correctly populating, checked that they are inside the canvas using the F12 debugging tool but they just are not visible. Help?
Canvas Model
Panel View Model
45 Replies
XAML View
Main Window View
Results
![No description](https://cdn.answeroverflow.com/1212164782271107112/image.png)
Wrong XAML layout. Your
ItemsControl
should be top and use an ItemsPanel
for the Canvas
. Check https://docs.avaloniaui.net/docs/concepts/custom-itemspanel for specificsAttached properties like
Canvas.Left
only get inspected when they're a direct child of the Canvas
control.Appreciate that. I’ll give it a try
No change 😦
XAML Code
![No description](https://cdn.answeroverflow.com/1212871664300326992/image.png)
Are you using compiled bindings?
can you elaborate a bit?
im just grabbing the value of a list variable of polylines in c#
looking at the docs i dont believe i am, wouldnt have a clue how to use them
like this?
That's one way. You should typically enable them project wide in csproj and use
{ReflectionBinding}
if you're limited in some scenario.
I need to leave for awhile though.your allgood. still didnt work but thanks for your help this far 🙂
This is weird because you're storing
Polyline
controls. You're also storing them in properties that don't raise INPC and in a collection that doesn't raise INotifyCollectionChanged
. So you need to be very careful about initialization order and when the binding happens.
You can try a ContentControl
instead, but I'm not entirely sure what happens when you try to wrap a control in it.
All I want to do is get a bunch of Polylines and smash them onto a canvas
how would you implement INotifyCollectionChanged to this?
What Mvvm framework are you using?
Avalonia.
Also is this an issue?
![No description](https://cdn.answeroverflow.com/1213190616297644062/image.png)
Avalonia is a GUI framework, not an MVVM framework.