Solved

Load Items into Canvas in WPF application

Posted on 2008-10-30
3
621 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…

828 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