3 Replies - 357 Views - Last Post: 08 February 2013 - 09:30 AM Rate Topic: -----

#1 oyyou  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 182
  • Joined: 26-April 10

Repeating a design. WPF

Posted 08 February 2013 - 08:48 AM

Okay, so I have a list of information, and I would like to have this information to be represent with labels and a rectangle.
The labels will have numbers in, and the rectangle will contain an image (The width changes depending on the information in the list).

So I want to make a template type thing
Something like a panel, where it contains labels and a rectangle and I can do something like
for(int i = 0; i < DiskInformation.Get().Count; i++)
    template.Add(new DiskUsageTemplate(xPos,yPos, infoA, infoB, infoC));



So with that, I can draw multiple little boxes of information.
But I have absolutely no idea where to start.

Thanks,
- Oyy

Is This A Good Question/Topic? 0
  • +

Replies To: Repeating a design. WPF

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5442
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Re: Repeating a design. WPF

Posted 08 February 2013 - 08:54 AM

Try making a UserControl with all of your components on it.
Then you place as many instances of the UserControl as you need.

That makes each UserControl a single item you deal with for this representation of a single thing.
Was This Post Helpful? 0
  • +
  • -

#3 oyyou  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 182
  • Joined: 26-April 10

Re: Repeating a design. WPF

Posted 08 February 2013 - 08:59 AM

That is what I've been trying to use.
I've got as far as creating a list of UserControls (All the same one)
But I'm not sure how I get the UserControl to draw on the current window.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5442
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Re: Repeating a design. WPF

Posted 08 February 2013 - 09:30 AM

In WinForms you could make a control then add it programmatically to another control's .Controls collection.

In WPF you add it to the .Children collection

http://social.msdn.m...96-dec075ce0b84
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1