Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How do you use MeasureOverride in Silverlight?
- protected override Size MeasureOverride(Size availableSize) {
- Size panelDesiredSize = new Size();
- if ((this.widthWrap) || (this.heightWrap))
- {
- foreach (UIElement elemento in this.Children)
- {
- System.Diagnostics.Debug.WriteLine(((FrameworkElement)elemento).DesiredSize.ToString());
- if (this.Orientation.Equals(System.Windows.Controls.Orientation.Vertical))
- {
- if (this.widthWrap)
- {
- //the widest element will determine containers width
- if (panelDesiredSize.Width < ((FrameworkElement)elemento).Width)
- panelDesiredSize.Width = ((FrameworkElement)elemento).Width;
- }
- //the height of the Layout is determine by the sum of all the elment that it cointains
- if (this.heightWrap)
- panelDesiredSize.Height += ((FrameworkElement)elemento).Height;
- }
- else
- {
- if (this.heightWrap)
- {
- //The highest will determine the height of the Layout
- if (panelDesiredSize.Height < ((FrameworkElement)elemento).Height)
- panelDesiredSize.Height = ((FrameworkElement)elemento).Height;
- }
- //The width of the container is the sum of all the elements widths
- if (this.widthWrap)
- panelDesiredSize.Width += ((FrameworkElement)elemento).Width;
- }
- }
- }
- System.Diagnostics.Debug.WriteLine("desiredsizzeeeeeee" + panelDesiredSize);
- return panelDesiredSize;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement