You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use FluentRibbon in a WPF app which use Caliburn.Micro.
Certainly because of the way caliburn micro (and my code) instanciates my UserControl where my ribbon is defined, the MeasureOverride for the RibbonTitleBar control is called with my entire screen width as constraint.
And because the methods returns the parameter instead of returning the real control dimension, my window's width is set to my entire screen width (instead of just what is needed).
MSDN states that MeasureOverride should return the real minimum size required by the control, and not the constraint size, as it could be interpreted as a required size for the control to be correctly displayed.
I have found a way to get the correct behavior, it requires 2 modifications:
Update MeasureOverride in RibbonTitleBar to return the real size instead of the constraint:
/// <summary>/// Called to remeasure a control./// </summary>/// <param name="constraint">The maximum size that the method can return.</param>/// <returns>The size of the control, up to the maximum specified by constraint.</returns>protectedoverrideSizeMeasureOverride(Sizeconstraint){if(this.isAtLeastOneRequiredControlPresent==false){returnbase.MeasureOverride(constraint);}if(this.IsCollapsed){returnbase.MeasureOverride(constraint);}varresultSize=constraint;if(double.IsPositiveInfinity(resultSize.Width)||double.IsPositiveInfinity(resultSize.Height)){resultSize=base.MeasureOverride(resultSize);}this.Update(resultSize);this.itemsContainer.Measure(this.itemsRect.Size);this.headerHolder.Measure(this.headerRect.Size);this.quickAccessToolbarHolder.Measure(this.quickAccessToolbarRect.Size);// We do not return resultsize anymore, instead we compute the real size required by the controls//return resultSize;varmaxHeight=Math.Max(Math.Max(this.itemsRect.Height,this.headerRect.Height),this.quickAccessToolbarRect.Height);varwidth=this.itemsRect.Width+this.headerRect.Width+this.quickAccessToolbarRect.Width;returnnewSize(width,maxHeight);}
Update the theme files. The previous change results in the titlebar being centered on the top of the window instead of using all the available space. The RibbonControlTemplate in Ribbon.xaml must be updated to set the Fluent:RibbonTitleBar left aligned. For example in Office2013 theme:
I found how to reproduce this behavior: by default, Caliburn.Micro set Window.SizeToContent to SizeToContent.WidthAndHeight. By default, this value is set to SizeToContent.Manual.
When you use SizeToContent.WidthAndHeight, I suppose the layout manager give the entire screen size as constraints, because the window can grow up.
Hi,
I am trying to use FluentRibbon in a WPF app which use Caliburn.Micro.
Certainly because of the way caliburn micro (and my code) instanciates my UserControl where my ribbon is defined, the
MeasureOverride
for theRibbonTitleBar
control is called with my entire screen width asconstraint
.And because the methods returns the parameter instead of returning the real control dimension, my window's width is set to my entire screen width (instead of just what is needed).
MSDN states that MeasureOverride should return the real minimum size required by the control, and not the constraint size, as it could be interpreted as a required size for the control to be correctly displayed.
I have found a way to get the correct behavior, it requires 2 modifications:
MeasureOverride
inRibbonTitleBar
to return the real size instead of the constraint:RibbonControlTemplate
inRibbon.xaml
must be updated to set theFluent:RibbonTitleBar
left aligned. For example in Office2013 theme:I can submit a PR with this bug, or let you fix this issue by yourself, as you prefer.
Thanks !
The text was updated successfully, but these errors were encountered: