/// <summary> /// Gets the element's desired size, using the specified available. /// </summary> /// <param name="element"></param> /// <param name="availableSize"></param> /// <returns></returns> public SizeF GetDesiredSize(RadElement element, SizeF availableSize) { //suspend theme updates for the element element.SuspendThemeRefresh(); RadElement parent = element.Parent; int indexInChildrenCollection = -1; if (parent != null) { indexInChildrenCollection = parent.Children.IndexOf(element); } ElementVisibility oldVisibility = element.Visibility; if (oldVisibility != ElementVisibility.Visible) { element.Visibility = ElementVisibility.Visible; } this.RootElement.Children.Add(element); element.ResetLayout(true); element.Measure(availableSize); SizeF desiredSize = element.GetDesiredSize(false); //add the element to its previous parent (it will be automatically removed from its current parent) if (parent != null) { parent.Children.Insert(indexInChildrenCollection, element); } else { this.RootElement.Children.Remove(element); } if (oldVisibility != ElementVisibility.Visible) { element.Visibility = oldVisibility; } element.ResumeThemeRefresh(); return(desiredSize); }
public virtual SizeF MeasureItem(Item item, SizeF availableSize) { IVirtualizedElement <Item> element = this.ViewElement.ElementProvider.GetElement(item, (object)null); RadElement radElement = (RadElement)element; this.SuspendLayout(); this.Children.Add(radElement); element.Attach(item, (object)null); radElement.ResetLayout(true); radElement.Measure(availableSize); SizeF desiredSize = radElement.GetDesiredSize(false); this.Children.Remove(radElement); this.ViewElement.ElementProvider.CacheElement(element); element.Detach(); this.ResumeLayout(false); return(desiredSize); }
public SizeF GetDesiredSize(RadElement element, SizeF availableSize) { element.SuspendThemeRefresh(); RadElement parent = element.Parent; int index = -1; if (parent != null) { index = parent.Children.IndexOf(element); } ElementVisibility visibility = element.Visibility; if (visibility != ElementVisibility.Visible) { element.Visibility = ElementVisibility.Visible; } this.RootElement.Children.Add(element); element.ResetLayout(true); element.Measure(availableSize); SizeF desiredSize = element.GetDesiredSize(false); if (parent != null) { parent.Children.Insert(index, element); } else { this.RootElement.Children.Remove(element); } if (visibility != ElementVisibility.Visible) { element.Visibility = visibility; } element.ResumeThemeRefresh(); return(desiredSize); }