How to display different object types on a canvas #12093
Unanswered
HowardPWeiss
asked this question in
Q&A
Replies: 1 comment
-
I had a similar problem, [Skia] Polyline shape is not displaying properly in Stretch.None mode when using negative coordinates #10651 . @jeromelaban was able to provide some help there - although he had previously suggestion that I switch from using CANVAS to using PANEL instead. Perhaps his suggestion might work for you as well.. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like add different object types (Line, TextBox) to a canvas in an MVVM WPF Application with .Net 7.0. I am using Visual Studio Code under Linux for development. I used the Uno template to generate 4 projects - , .Base, .Skia.GTK and .Windows. Under Visual Studio Code, I open a terminal window and cd to .Skia.GTK . I then enter "dotnet run" in the terminal window to build and run the application
In XAML, I have created an ItemsControl to display objects on the canvas as follows:
LineObject and TextBlockl Object are defined in my ViewModel as follows
public class TextBlockObject : Object
{
public double X {get;set;}
public double Y {get; set;}
public double Height {get;set;}
public double Width {get; set;}
public string Name {get; set;}
public string Foreground {get;set;}
public string Text {get; set;}
}
and ObjectCollection is defined as
public ObservableCollection ObjectCollection {get; set;}
and initialized as follows
ObjectCollection = new ObservableCollection();
At runtime, I add 5 objects to the object collection - 1 TextBlockObject and 4 LineObjects. I am expecting that and will apply the datatemplate to each object based on the type of the object
What I see is that the 4 LineObjects are drawn on the canvas and the TextBlockObject is not drawn. If I switch the order of the DataTemplate definitions so that the TextBlockObject DataTemplate is first, then the TextBlockObject is drawn and the 4 LineObjects are not drawn
Note that DataTemplateSelector cannot be defined since the namespaces in DataTemplateSelector are defined are not included in Net 7.0
Please advise
Howard Weiss
Beta Was this translation helpful? Give feedback.
All reactions