diff --git a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/OtherExamples.xaml b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/OtherExamples.xaml
index d24338e779..70b708d270 100644
--- a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/OtherExamples.xaml
+++ b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/ExampleViews/OtherExamples.xaml
@@ -109,9 +109,33 @@
Grid.Column="1"
Grid.ColumnSpan="2">
+
+
+
+
+
+
+
+
+
-
+
@@ -120,47 +144,48 @@
-
-
+
-
-
-
+ SelectedValue="{Binding ElementName=FlipView1st, Path=Orientation, FallbackValue={x:Static Orientation.Horizontal}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+
+
+ SelectedValue="{Binding ElementName=FlipView1st, Path=NavigationButtonsPosition, FallbackValue={x:Static mah:NavigationButtonsPosition.Inside}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
+
+
+
+
+ Foreground="{DynamicResource MahApps.Brushes.ThemeBackground}"
+ IndexHorizontalAlignment="Right"
+ IndexPlacement="TopOverItem"
+ ShowIndex="True">
+
@@ -204,18 +230,18 @@
+
+ Orientation="{Binding ElementName=Orientation, Path=SelectedValue, Mode=OneWay}"
+ ShowIndex="True" />
diff --git a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/Markup/EnumBindingSourceExtension.cs b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/Markup/EnumBindingSourceExtension.cs
index a63137d59f..0193142a77 100644
--- a/src/MahApps.Metro.Samples/MahApps.Metro.Demo/Markup/EnumBindingSourceExtension.cs
+++ b/src/MahApps.Metro.Samples/MahApps.Metro.Demo/Markup/EnumBindingSourceExtension.cs
@@ -10,10 +10,9 @@ namespace MetroDemo.Markup
///
/// Markup extension for Enum values.
///
- public class EnumBindingSourceExtension
- : MarkupExtension
+ public class EnumBindingSourceExtension : MarkupExtension
{
- private Type _EnumType;
+ private Type enumType;
///
/// Gets or sets the type of the Enum.
@@ -21,15 +20,22 @@ public class EnumBindingSourceExtension
/// Value is not an Enum type.
public Type EnumType
{
- get { return this._EnumType; }
+ get => this.enumType;
set
{
- if (!Object.Equals(value, this.EnumType))
+ if (value != this.enumType)
{
- if (!Object.Equals(value, null) && !(Nullable.GetUnderlyingType(value) ?? value).IsEnum)
- throw new ArgumentException("Type must be an Enum.");
+ if (null != value)
+ {
+ var type = Nullable.GetUnderlyingType(value) ?? value;
- this._EnumType = value;
+ if (!type.IsEnum)
+ {
+ throw new ArgumentException("Type must be for an Enum.");
+ }
+ }
+
+ this.enumType = value;
}
}
}
@@ -50,23 +56,23 @@ public EnumBindingSourceExtension(Type enumType)
this.EnumType = enumType;
}
- ///
- ///
- ///
- /// Object that can provide services for the markup extension.
- /// The values of the Enum.
- /// The type of the Enum is undefined.
+ ///
public override object ProvideValue(IServiceProvider serviceProvider)
{
- if (Object.Equals(this.EnumType, null))
- throw new InvalidOperationException("The type of the Enum is undefined.");
+ if (this.EnumType is null)
+ {
+ throw new InvalidOperationException("The EnumType must be specified.");
+ }
var underlyingEnumType = Nullable.GetUnderlyingType(this.EnumType) ?? this.EnumType;
var enumValues = Enum.GetValues(underlyingEnumType);
- if (underlyingEnumType.Equals(this.EnumType))
+
+ if (underlyingEnumType == this.EnumType)
+ {
return enumValues;
+ }
- var nullableEnumValues = Array.CreateInstance(underlyingEnumType, enumValues.Length);
+ var nullableEnumValues = Array.CreateInstance(underlyingEnumType, enumValues.Length + 1);
enumValues.CopyTo(nullableEnumValues, 1);
return nullableEnumValues;
}
diff --git a/src/MahApps.Metro/Controls/FlipView.cs b/src/MahApps.Metro/Controls/FlipView.cs
index 5127cca24f..35b2960a99 100644
--- a/src/MahApps.Metro/Controls/FlipView.cs
+++ b/src/MahApps.Metro/Controls/FlipView.cs
@@ -27,6 +27,7 @@ namespace MahApps.Metro.Controls
[TemplatePart(Name = PART_BannerGrid, Type = typeof(Grid))]
[TemplatePart(Name = PART_BannerLabel, Type = typeof(Label))]
[StyleTypedProperty(Property = nameof(NavigationButtonStyle), StyleTargetType = typeof(Button))]
+ [StyleTypedProperty(Property = nameof(IndexItemContainerStyle), StyleTargetType = typeof(ListBoxItem))]
public class FlipView : Selector
{
/// Identifies the dependency property.
@@ -77,6 +78,84 @@ public Thickness MouseHoverBorderThickness
set => this.SetValue(MouseHoverBorderThicknessProperty, value);
}
+ /// Identifies the dependency property.
+ public static readonly DependencyProperty ShowIndexProperty
+ = DependencyProperty.Register(nameof(ShowIndex),
+ typeof(bool),
+ typeof(FlipView),
+ new FrameworkPropertyMetadata(BooleanBoxes.FalseBox, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange));
+
+ ///
+ /// Gets or sets a value indicating whether the navigation index should be visible.
+ ///
+ public bool ShowIndex
+ {
+ get => (bool)this.GetValue(ShowIndexProperty);
+ set => this.SetValue(ShowIndexProperty, BooleanBoxes.Box(value));
+ }
+
+ /// Identifies the dependency property.
+ public static readonly DependencyProperty IndexItemContainerStyleProperty
+ = DependencyProperty.Register(nameof(IndexItemContainerStyle),
+ typeof(Style),
+ typeof(FlipView),
+ new FrameworkPropertyMetadata(default(Style), FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange));
+
+ ///
+ /// Gets or sets a style for the navigation index items.
+ ///
+ public Style IndexItemContainerStyle
+ {
+ get => (Style)this.GetValue(IndexItemContainerStyleProperty);
+ set => this.SetValue(IndexItemContainerStyleProperty, value);
+ }
+
+ /// Identifies the dependency property.
+ public static readonly DependencyProperty IndexPlacementProperty
+ = DependencyProperty.Register(nameof(IndexPlacement),
+ typeof(NavigationIndexPlacement),
+ typeof(FlipView),
+ new FrameworkPropertyMetadata(NavigationIndexPlacement.Bottom, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange));
+
+ ///
+ /// Gets or sets a value specifying where the navigation index should be rendered.
+ ///
+ public NavigationIndexPlacement IndexPlacement
+ {
+ get => (NavigationIndexPlacement)this.GetValue(IndexPlacementProperty);
+ set => this.SetValue(IndexPlacementProperty, value);
+ }
+
+ public static readonly DependencyProperty IndexHorizontalAlignmentProperty
+ = DependencyProperty.Register(nameof(IndexHorizontalAlignment),
+ typeof(HorizontalAlignment),
+ typeof(FlipView),
+ new FrameworkPropertyMetadata(HorizontalAlignment.Center, FrameworkPropertyMetadataOptions.AffectsArrange));
+
+ ///
+ /// Gets or sets the horizontal alignment characteristics applied to the navigation index.
+ ///
+ public HorizontalAlignment IndexHorizontalAlignment
+ {
+ get => (HorizontalAlignment)this.GetValue(IndexHorizontalAlignmentProperty);
+ set => this.SetValue(IndexHorizontalAlignmentProperty, (object)value);
+ }
+
+ public static readonly DependencyProperty IndexVerticalAlignmentProperty
+ = DependencyProperty.Register(nameof(IndexVerticalAlignment),
+ typeof(VerticalAlignment),
+ typeof(FlipView),
+ new FrameworkPropertyMetadata(VerticalAlignment.Center, FrameworkPropertyMetadataOptions.AffectsArrange));
+
+ ///
+ /// Gets or sets the vertical alignment characteristics applied to the navigation index.
+ ///
+ public VerticalAlignment IndexVerticalAlignment
+ {
+ get => (VerticalAlignment)this.GetValue(IndexVerticalAlignmentProperty);
+ set => this.SetValue(IndexVerticalAlignmentProperty, (object)value);
+ }
+
/// Identifies the dependency property.
public static readonly DependencyProperty CircularNavigationProperty
= DependencyProperty.Register(nameof(CircularNavigation),
diff --git a/src/MahApps.Metro/Controls/NavigationIndexPlacement.cs b/src/MahApps.Metro/Controls/NavigationIndexPlacement.cs
new file mode 100644
index 0000000000..32f91d1ddf
--- /dev/null
+++ b/src/MahApps.Metro/Controls/NavigationIndexPlacement.cs
@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace MahApps.Metro.Controls
+{
+ ///
+ /// For specifying where the navigation index is placed relative to the .
+ ///
+ public enum NavigationIndexPlacement
+ {
+ ///
+ /// Index on left side
+ ///
+ Left,
+ ///
+ /// Index on right side
+ ///
+ Right,
+ ///
+ /// Index on top side
+ ///
+ Top,
+ ///
+ /// Index on bottom side
+ ///
+ Bottom,
+
+ ///
+ /// Index on left side over the item
+ ///
+ LeftOverItem,
+ ///
+ /// Index on right side over the item
+ ///
+ RightOverItem,
+ ///
+ /// Index on top side over the item
+ ///
+ TopOverItem,
+ ///
+ /// Index on bottom side over the item
+ ///
+ BottomOverItem
+ }
+}
\ No newline at end of file
diff --git a/src/MahApps.Metro/Themes/FlipView.xaml b/src/MahApps.Metro/Themes/FlipView.xaml
index dd3202e63e..ea91665f43 100644
--- a/src/MahApps.Metro/Themes/FlipView.xaml
+++ b/src/MahApps.Metro/Themes/FlipView.xaml
@@ -1,6 +1,11 @@
+ xmlns:mah="clr-namespace:MahApps.Metro.Controls"
+ xmlns:system="clr-namespace:System;assembly=mscorlib">
+
+
+
+ 15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+