Solved

Load Items into Canvas in WPF application

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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