Question

I want to create a WPF application in C# that shows skeletons from 2 different Kinects at the same time. For that I created an ArrayList to hold DrawingGroup objects for separate Kinects. When I try to add the DrawingImage into the image sources arraylist then it gives me the error about new DrawingImage(ImageGroup) having the wrong argument in it.

drawingGroups.Add(new DrawingGroup(););
imageSources.Add(new DrawingImage(drawingGroups[sensors-1]);
Was it helpful?

Solution

You said that you have an ArrayList of DrawingGroup objects. When you get elements of this collection by the indexer [] (in drawingGroups[sensors-1]), you just get an object instead of a DrawingGroup. You could cast the object to DrawingGroup, but it would be better to use a strongly typed collection like List<T>.

Just change the type of drawingGroups to List<DrawingGroup>:

using System.Collections.Generic;
...

var drawingGroups = new List<DrawingGroup>();

drawingGroups.Add(new DrawingGroup());
imageSources.Add(new DrawingImage(drawingGroups[sensors-1]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top