Solved

Load Items into Canvas in WPF application

Posted on 2008-10-30
3
619 Views
Last Modified: 2013-11-26
Hi,

I am using the code below to load Items into my Canvas. This works fine, but it throws out the items (as you can see) in random. I want to be able to load the items in a list form, but do not want to use a list box. How will I be able to load them next to each other from left to right and then when the Canvas gets full to continue in the row below?

Thanks
Private Function GetRandomDist(ByVal limit As Double) As Double
Return rand.NextDouble() * limit
End Function
 
Private Sub LoadItem(ByVal PictureName As String _
                         , ByVal ItemLookupCode As String _
                         , ByVal ExtendedDescription As String _
                         , ByVal Number As Integer)
 
Dim mycontrol As New ItemControl()
mycontrol.SetValue(Canvas.LeftProperty, GetRandomDist(ItemAddCanvas.ActualWidth + 450))
mycontrol.SetValue(Canvas.TopProperty, GetRandomDist(ItemAddCanvas.ActualHeight + 450))
mycontrol.EXTDesc.Text = ExtendedDescription
mycontrol.ItemCode.Content = ItemLookupCode
mycontrol.ItemImage.Source = New BitmapImage(New Uri(PictureName))
ItemAddCanvas.Children.Add(mycontrol)
End Sub

Open in new window

0
Comment
Question by:ALawrence007
  • 2
3 Comments
 

Author Comment

by:ALawrence007
ID: 22939270
Any experts that might be able to help?
0
 
LVL 8

Accepted Solution

by:
adler77 earned 500 total points
ID: 23126183
You might want to use a WrapPanel instead of a Canvas--it will let you add items to it and then automatically wrap to the next "line" as needed. You would also have the benefit of it auto-arranging if the size of your panel changes.
0
 

Author Closing Comment

by:ALawrence007
ID: 31511638
I had this open for a while and this actually solved my issue.
Thanks adler77
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question