Star Sizing with Viewboxes

Page 1 of 1

1 Replies - 878 Views - Last Post: 26 September 2011 - 01:53 AM Rate Topic: -----

#1 Robin19  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 271
  • View blog
  • Posts: 550
  • Joined: 07-July 10

Star Sizing with Viewboxes

Posted 24 September 2011 - 11:36 AM

My application will be used on different sized monitors. Because of this, I am using star sizing on grids for all of the layout work. My problem is that I'd also like to use the Viewbox to autosize my text. It looks like that the star sizing is changed to accomadate the viewbox, but I'd like the viewbox to adjust itself and the star sizing have priority. What would be the best way to go about this?

I create a short version of what I have going on.

Person.cs
Spoiler


PersonViewModel.cs
Spoiler


PersonControl.xaml
Spoiler


Mainwindow.xaml
Spoiler


Mainwindow.cs
Spoiler


Click the "Add" button 3 times. It adds the people, but the user controls are obviously out of alignment. I want the text for the name to autosize itself (they would be different sized) so that everything remains lined up. Instead it gives the text as much room as it likes and messes up my star sizing. Does anyone have a solution?

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Star Sizing with Viewboxes

#2 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 170
  • View blog
  • Posts: 637
  • Joined: 07-October 08

Re: Star Sizing with Viewboxes

Posted 26 September 2011 - 01:53 AM

You could create a class that inherits from ListBox and override the OnChildDesiredSizeChanged method so that whenever a child is added or removed you could itterate the items in the list box and find which one of your PersonControl has the widest column definition for name column, and then itterate again and change each control to match that width. You could probably even bind this fairly easily.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1