How to Add Elements To Canvas From List
-
Sonntag, 6. Mai 2012 11:05
Hi!
Sorry, I don't know if it's a basic question or not, i couldn't find anything on the interner.
I'd like to place positioned items in a grid from a list. This list has items with properies Top and Left. I figured out, i would need a canvas to make my task, but i dont know how to make this from XAML. I tried putting an ItemsControl into the Canvas and bind the Canvas.Top to the Top property, but it didn't work. Then i tried to add my items from code, like this:
foreach (var item in MyElements) { Image img = new Image(); img.Source = item.MainImage; img.Width = 20; img.Height = 20; img.Stretch = Stretch.UniformToFill; MyCanvas.Children.Add(img); }
but this way i don't know how to tell the images' position.
So as a summary, how can i add items to a canvas from a List?
Thanks,
Tom
- Verschoben Jeff SandersMicrosoft Employee, Moderator Montag, 7. Mai 2012 12:26 Xaml Specific (From:UI Design for Metro style apps)
Alle Antworten
-
Montag, 7. Mai 2012 15:18Moderator
Please see Canvas.SetLeft and Canvas.SetTop:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.canvas.setleft.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.canvas.settop.aspxMatt Small - Microsoft Escalation Engineer - Forum Moderator If my reply answers your question, please mark this post as answered.
- Als Antwort vorgeschlagen Matt SmallMicrosoft Employee, Moderator Montag, 7. Mai 2012 15:18
- Als Antwort markiert Bob_BaoMVP, Moderator Donnerstag, 7. Juni 2012 09:20

