Skip to content

Commit

Permalink
Fixes #440 by introducing ContentHeight
Browse files Browse the repository at this point in the history
ContentHeight is available on Ribbon and tranferred to RibbonTabControl from there
  • Loading branch information
batzen committed Jun 5, 2017
1 parent 7eba00e commit 41f1319
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
- [#313](../../issues/313) - Window state buttons not updating to Windows 10 look / feel
- [#417](../../issues/417) - Keytips for Splitbuttons
You now get 2 KeyTips for `SplitButton`. One for the main action button and one for the dropdown. Those KeyTips get generated by append "A" and "B" to the original `KeyTip`.
- [#440](../../issues/440) - Enable changing the height of content area of RibbonTabControl
`ContentHeight` is available on `Ribbon` and tranferred to `RibbonTabControl` from there

## 5.0.2
- [#437](../../issues/437) - "Could not load ControlzEx"
Expand Down
17 changes: 16 additions & 1 deletion Fluent.Ribbon/Controls/Ribbon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ private static void OnCanMinimizeChanged(DependencyObject d, DependencyPropertyC
}

/// <summary>
/// Gets or sets the height of the gap between the ribbon and the content
/// Gets or sets the height of the gap between the ribbon and the regular window content
/// </summary>
public double ContentGapHeight
{
Expand All @@ -1136,6 +1136,21 @@ public double ContentGapHeight
public static readonly DependencyProperty ContentGapHeightProperty =
DependencyProperty.Register(nameof(ContentGapHeight), typeof(double), typeof(Ribbon), new PropertyMetadata(1D));

/// <summary>
/// Gets or sets the height of the ribbon content area
/// </summary>
public double ContentHeight
{
get { return (double)this.GetValue(ContentHeightProperty); }
set { this.SetValue(ContentHeightProperty, value); }
}

/// <summary>
/// DependencyProperty for <see cref="ContentHeight"/>
/// </summary>
public static readonly DependencyProperty ContentHeightProperty =
DependencyProperty.Register(nameof(ContentHeight), typeof(double), typeof(Ribbon), new PropertyMetadata(RibbonTabControl.DefaultContentHeight));

// todo check if IsCollapsed and IsAutomaticCollapseEnabled should be reduced to one shared property for RibbonWindow and Ribbon
/// <summary>
/// Gets whether ribbon is collapsed
Expand Down
7 changes: 5 additions & 2 deletions Fluent.Ribbon/Controls/RibbonGroupBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ internal Size DesiredSizeIntermediate

if (this.cachedMeasures.TryGetValue(stateScale, out result) == false)
{
var contentHeight = UIHelper.GetParent<RibbonTabControl>(this)?.ContentHeight ?? RibbonTabControl.DefaultContentHeight;

this.SuppressCacheReseting = true;
this.UpdateScalableControlSubscribing();

Expand All @@ -780,15 +782,16 @@ internal Size DesiredSizeIntermediate
this.State = this.StateIntermediate;
this.Scale = this.ScaleIntermediate;
this.InvalidateLayout();
this.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
this.Measure(new Size(double.PositiveInfinity, contentHeight));
this.cachedMeasures.Remove(stateScale);
this.cachedMeasures.Add(stateScale, this.DesiredSize);
result = this.DesiredSize;

// Rollback changes
this.State = backupState;
this.Scale = backupScale;
this.InvalidateLayout();
this.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
this.Measure(new Size(double.PositiveInfinity, contentHeight));

this.SuppressCacheReseting = false;
}
Expand Down
12 changes: 12 additions & 0 deletions Fluent.Ribbon/Controls/RibbonTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace Fluent
[TemplatePart(Name = "PART_SelectedContentPresenter", Type = typeof(ContentPresenter))]
public class RibbonTabControl : Selector, IDropDownControl
{
public const double DefaultContentHeight = 94;

#region Fields

// Collection of toolbar items
Expand Down Expand Up @@ -278,6 +280,16 @@ private void OnToolbarItemsCollectionChanged(object sender, NotifyCollectionChan

}

public double ContentHeight
{
get { return (double)this.GetValue(ContentHeightProperty); }
set { this.SetValue(ContentHeightProperty, value); }
}

// Using a DependencyProperty as the backing store for ContentHeight. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ContentHeightProperty =
DependencyProperty.Register(nameof(ContentHeight), typeof(double), typeof(RibbonTabControl), new FrameworkPropertyMetadata(DefaultContentHeight, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));

/// <summary>
/// Gets or sets the height of the gap between the ribbon and the content
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion Fluent.Ribbon/Themes/Controls/Ribbon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
</Grid.RowDefinitions>
<Fluent:RibbonTabControl x:Name="PART_RibbonTabControl"
Background="{TemplateBinding Background}"
Menu="{TemplateBinding Menu}"
Menu="{TemplateBinding Menu}"
ContentHeight="{TemplateBinding ContentHeight}"
ContextMenu="{Binding ContextMenu, ElementName=PART_LayoutRoot}" />

<ContentControl x:Name="quickAccessToolBarHolder"
Expand Down
4 changes: 2 additions & 2 deletions Fluent.Ribbon/Themes/Controls/RibbonGroupBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Setter Property="Width"
Value="Auto" />
<Setter Property="Height"
Value="85" />
Value="Auto" />
<Setter Property="HorizontalContentAlignment"
Value="Left" />
<Setter Property="Foreground"
Expand Down Expand Up @@ -291,7 +291,7 @@
<Grid x:Name="PART_ParentPanel"
Margin="0,1,0,2"
Grid.RowSpan="2"
Height="85">
Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="17" />
Expand Down
6 changes: 4 additions & 2 deletions Fluent.Ribbon/Themes/Controls/RibbonTabControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition x:Name="rowDefinition"
Height="94" />
MinHeight="{TemplateBinding ContentHeight}"
MaxHeight="{TemplateBinding ContentHeight}" />
<RowDefinition x:Name="rowDefinition1"
MinHeight="{TemplateBinding ContentGapHeight}"
MaxHeight="{TemplateBinding ContentGapHeight}" />
Expand All @@ -261,6 +262,7 @@
BorderThickness="0,1"
Grid.Row="1"
BorderBrush="{Binding Path=SelectedItem.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />

<Border HorizontalAlignment="Stretch"
Margin="1,0,1,1"
Grid.Row="1"
Expand Down Expand Up @@ -371,7 +373,7 @@
<ControlTemplate.Triggers>
<Trigger Property="IsMinimized"
Value="True">
<Setter Property="Height"
<Setter Property="MinHeight"
TargetName="rowDefinition"
Value="0" />
<Setter Property="MinHeight"
Expand Down

0 comments on commit 41f1319

Please sign in to comment.