Solved

Load Items into Canvas in WPF application

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

896 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

11 Experts available now in Live!

Get 1:1 Help Now