Skip to content

Commit

Permalink
Change default CanResizeOpenPane to false and add ToggleSwitches to Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
timunie committed May 10, 2020
1 parent b29169e commit cf32ec1
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 73 deletions.
29 changes: 29 additions & 0 deletions src/MahApps.Metro.Samples/MahApps.Metro.Demo/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@
</ObjectAnimationUsingKeyFrames>
</Storyboard>

<Style TargetType="controls:MetroHeader" x:Key="MahApps.Styles.MetroHeader.Horizontal">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:MetroHeader">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="HeaderGroup" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<ContentPresenter Content="{TemplateBinding Header}"
ContentStringFormat="{TemplateBinding HeaderStringFormat}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
Grid.Column="0"
VerticalAlignment="Center" />
<ContentPresenter Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
Grid.Column="1"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
Header="IsPaneOpen:"
IsOn="{Binding ElementName=HamburgerMenuControl, Path=IsPaneOpen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<Controls:ToggleSwitch Margin="0 10 0 5"
Header="CanResizeOpenPane:"
IsOn="{Binding ElementName=HamburgerMenuControl, Path=CanResizeOpenPane, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />


<Controls:MetroHeader Margin="0 10 0 5" Header="DisplayMode:">
<ComboBox MinWidth="150"
HorizontalAlignment="Left"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
Header="IsPaneOpen:"
IsOn="{Binding IsHamburgerMenuPaneOpen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<Controls:ToggleSwitch Margin="0 10 0 5"
Header="CanResizeOpenPane:"
IsOn="{Binding ElementName=HamburgerMenuControl, Path=CanResizeOpenPane, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<Controls:MetroHeader Margin="0 10 0 5" Header="PanePlacement:">
<ComboBox MinWidth="150"
HorizontalAlignment="Left"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,75 +27,45 @@

<!-- #Templates -->
<ControlTemplate x:Key="ConfigDataTemplate">
<Grid d:DataContext="{d:DesignInstance controls:SplitView}" Grid.IsSharedSizeScope="True">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="labels" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBlock Grid.Row="0"
Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="IsOpen" />
<CheckBox Grid.Row="0"
Grid.Column="1"
Margin="2"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{Binding IsPaneOpen}" />

<TextBlock Grid.Row="1"
Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="DisplayMode" />
<ComboBox Grid.Row="1"
Grid.Column="1"
Margin="2"
VerticalAlignment="Center"
<ControlTemplate.Resources>
<Style TargetType="controls:MetroHeader" BasedOn="{StaticResource MahApps.Styles.MetroHeader.Horizontal}" />
</ControlTemplate.Resources>
<StackPanel d:DataContext="{d:DesignInstance controls:SplitView}" Grid.IsSharedSizeScope="True">


<controls:MetroHeader Header="IsOpen">
<controls:ToggleSwitch IsOn="{Binding IsPaneOpen}" Margin="2" />
</controls:MetroHeader>

<controls:MetroHeader Header="DisplayMode">
<ComboBox Margin="2"
SelectedValue="{Binding DisplayMode}">
<controls:SplitViewDisplayMode>Inline</controls:SplitViewDisplayMode>
<controls:SplitViewDisplayMode>Overlay</controls:SplitViewDisplayMode>
<controls:SplitViewDisplayMode>CompactInline</controls:SplitViewDisplayMode>
<controls:SplitViewDisplayMode>CompactOverlay</controls:SplitViewDisplayMode>
</ComboBox>

<TextBlock Grid.Row="2"
Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="PanePlacement" />
<ComboBox Grid.Row="2"
Grid.Column="1"
Margin="2"
VerticalAlignment="Center"
<controls:SplitViewDisplayMode>Inline</controls:SplitViewDisplayMode>
<controls:SplitViewDisplayMode>Overlay</controls:SplitViewDisplayMode>
<controls:SplitViewDisplayMode>CompactInline</controls:SplitViewDisplayMode>
<controls:SplitViewDisplayMode>CompactOverlay</controls:SplitViewDisplayMode>
</ComboBox>
</controls:MetroHeader>

<controls:MetroHeader Header="CanResizeOpenPane">
<controls:ToggleSwitch IsOn="{Binding CanResizeOpenPane}" Margin="2" />
</controls:MetroHeader>

<controls:MetroHeader Header="PanePlacement">
<ComboBox Margin="2"
SelectedValue="{Binding PanePlacement}">
<controls:SplitViewPanePlacement>Left</controls:SplitViewPanePlacement>
<controls:SplitViewPanePlacement>Right</controls:SplitViewPanePlacement>
</ComboBox>

<TextBlock Grid.Row="3"
Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
Text="CancelClose" />
<CheckBox Grid.Row="3"
Grid.Column="1"
<controls:SplitViewPanePlacement>Left</controls:SplitViewPanePlacement>
<controls:SplitViewPanePlacement>Right</controls:SplitViewPanePlacement>
</ComboBox>
</controls:MetroHeader>

<controls:MetroHeader Header="CancelClose">
<controls:ToggleSwitch
Margin="2"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{Binding Tag, Mode=TwoWay}" />
</Grid>
IsOn="{Binding Tag, Mode=TwoWay}" />
</controls:MetroHeader>

</StackPanel>
</ControlTemplate>
</ResourceDictionary>
</UserControl.Resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@
Header="IsPaneOpen:"
IsOn="{Binding ElementName=HamburgerMenuControl, Path=IsPaneOpen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<Controls:ToggleSwitch Margin="0 10 0 5"
Header="CanResizeOpenPane:"
IsOn="{Binding ElementName=HamburgerMenuControl, Path=CanResizeOpenPane, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

<Controls:MetroHeader Margin="0 10 0 5" Header="DisplayMode:">
<ComboBox MinWidth="150"
HorizontalAlignment="Left"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ public double MaximumOpenPaneLength


/// <summary>Identifies the <see cref="CanResizeOpenPane"/> dependency property.</summary>
public static readonly DependencyProperty CanResizeOpenPaneProperty = DependencyProperty.Register(nameof(CanResizeOpenPane), typeof(bool), typeof(HamburgerMenu), new PropertyMetadata(true));
public static readonly DependencyProperty CanResizeOpenPaneProperty = DependencyProperty.Register(nameof(CanResizeOpenPane), typeof(bool), typeof(HamburgerMenu), new PropertyMetadata(false));

/// <summary>
/// Gets or Sets if the open pane can be resized by the user. The default value is true.
/// Gets or Sets if the open pane can be resized by the user. The default value is false.
/// </summary>
public bool CanResizeOpenPane
{
Expand Down
4 changes: 2 additions & 2 deletions src/MahApps.Metro/Controls/SplitView/SplitView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ public double MaximumOpenPaneLength


/// <summary>Identifies the <see cref="CanResizeOpenPane"/> dependency property.</summary>
public static readonly DependencyProperty CanResizeOpenPaneProperty = DependencyProperty.Register(nameof(CanResizeOpenPane), typeof(bool), typeof(SplitView), new PropertyMetadata(true));
public static readonly DependencyProperty CanResizeOpenPaneProperty = DependencyProperty.Register(nameof(CanResizeOpenPane), typeof(bool), typeof(SplitView), new PropertyMetadata(false));

/// <summary>
/// Gets or Sets if the open pane can be resized by the user. The default value is true.
/// Gets or Sets if the open pane can be resized by the user. The default value is false.
/// </summary>
public bool CanResizeOpenPane
{
Expand Down
2 changes: 1 addition & 1 deletion src/MahApps.Metro/Themes/HamburgerMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Setter Property="ResizeThumbStyle" Value="{DynamicResource MahApps.Styles.MetroThumb.SplitView.Resize}" />
<Setter Property="MinimumOpenPaneLength" Value="100" />
<Setter Property="MaximumOpenPaneLength" Value="500" />
<Setter Property="CanResizeOpenPane" Value="True" />
<Setter Property="CanResizeOpenPane" Value="False" />
<Setter Property="HamburgerButtonTemplate">
<Setter.Value>
<DataTemplate>
Expand Down
5 changes: 3 additions & 2 deletions src/MahApps.Metro/Themes/SplitView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<Setter Property="CompactPaneLength" Value="48" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="OpenPaneLength" Value="320" />
<Setter Property="MinimumOpenPaneLength" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=CompactPaneLength, Converter={converter:MathMultiplyConverter}, ConverterParameter=3}" />
<Setter Property="MaximumOpenPaneLength" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=ActualWidth, Converter={converter:MathMultiplyConverter}, ConverterParameter=0.8}" />
<Setter Property="MinimumOpenPaneLength" Value="100" />
<Setter Property="MaximumOpenPaneLength" Value="500" />
<Setter Property="CanResizeOpenPane" Value="False" />
<Setter Property="PaneBackground" Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" />
<Setter Property="PaneForeground" Value="{DynamicResource MahApps.Brushes.Text}" />
<Setter Property="ResizeThumbStyle" Value="{StaticResource MahApps.Styles.MetroThumb.SplitView.Resize}" />
Expand Down

0 comments on commit cf32ec1

Please # to comment.