Solved

Load Items into Canvas in WPF application

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now