Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Jul 2, 2020
2 parents fac568c + 7bf17ee commit d57ce8a
Show file tree
Hide file tree
Showing 55 changed files with 441 additions and 364 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void HamburgerMenuControl_OnItemInvoked(object sender, HamburgerMenuItem
public class BindingProxy : Freezable
{
// Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
public static readonly DependencyProperty DataProperty = DependencyProperty.Register(nameof(Data), typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));

public object Data
{
Expand All @@ -71,7 +71,7 @@ protected override Freezable CreateInstanceCore()

public static class ShowAboutCommand
{
public static readonly RoutedCommand Command = new RoutedCommand("Command", typeof(ShowAboutCommand));
public static readonly RoutedCommand Command = new RoutedCommand(nameof(Command), typeof(ShowAboutCommand));

static ShowAboutCommand()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public MainWindow()
}

public static readonly DependencyProperty ToggleFullScreenProperty =
DependencyProperty.Register("ToggleFullScreen",
DependencyProperty.Register(nameof(ToggleFullScreen),
typeof(bool),
typeof(MainWindow),
new PropertyMetadata(default(bool), OnToggleFullScreenChanged));
Expand Down Expand Up @@ -63,7 +63,7 @@ public bool ToggleFullScreen
}

public static readonly DependencyProperty UseAccentForDialogsProperty =
DependencyProperty.Register("UseAccentForDialogs",
DependencyProperty.Register(nameof(UseAccentForDialogs),
typeof(bool),
typeof(MainWindow),
new PropertyMetadata(default(bool), OnUseAccentForDialogsChanged));
Expand Down
3 changes: 2 additions & 1 deletion src/MahApps.Metro/Actions/CloseFlyoutAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MahApps.Metro.Controls;
using MahApps.Metro.ValueBoxes;

namespace MahApps.Metro.Actions
{
Expand Down Expand Up @@ -26,7 +27,7 @@ protected override void Invoke(object parameter)
}
else
{
this.AssociatedFlyout?.SetCurrentValue(Flyout.IsOpenProperty, false);
this.AssociatedFlyout?.SetCurrentValue(Flyout.IsOpenProperty, BooleanBoxes.FalseBox);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/MahApps.Metro/Actions/CommandTriggerAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Windows;
using System.Windows.Input;
using MahApps.Metro.ValueBoxes;
using Microsoft.Xaml.Behaviors;

namespace MahApps.Metro.Actions
Expand Down Expand Up @@ -117,7 +118,7 @@ private void EnableDisableElement()
}

var command = this.Command;
this.AssociatedObject.SetCurrentValue(UIElement.IsEnabledProperty, command == null || command.CanExecute(this.GetCommandParameter()));
this.AssociatedObject.SetCurrentValue(UIElement.IsEnabledProperty, BooleanBoxes.Box(command == null || command.CanExecute(this.GetCommandParameter())));
}

private void OnCommandCanExecuteChanged(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions src/MahApps.Metro/Behaviors/BindableResourceBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace MahApps.Metro.Behaviors
{
public class BindableResourceBehavior : Behavior<Shape>
{
public static readonly DependencyProperty ResourceNameProperty = DependencyProperty.Register("ResourceName", typeof (string), typeof (BindableResourceBehavior), new PropertyMetadata(default(string)));
public static readonly DependencyProperty PropertyProperty = DependencyProperty.Register("Property", typeof (DependencyProperty), typeof (BindableResourceBehavior), new PropertyMetadata(default(DependencyProperty)));
public static readonly DependencyProperty ResourceNameProperty = DependencyProperty.Register(nameof(ResourceName), typeof (string), typeof (BindableResourceBehavior), new PropertyMetadata(default(string)));
public static readonly DependencyProperty PropertyProperty = DependencyProperty.Register(nameof(Property), typeof (DependencyProperty), typeof (BindableResourceBehavior), new PropertyMetadata(default(DependencyProperty)));

protected override void OnAttached()
{
Expand Down
3 changes: 2 additions & 1 deletion src/MahApps.Metro/Behaviors/DatePickerTextBoxBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows.Controls.Primitives;
using System.Windows.Threading;
using MahApps.Metro.Controls;
using MahApps.Metro.ValueBoxes;
using Microsoft.Xaml.Behaviors;

namespace MahApps.Metro.Behaviors
Expand Down Expand Up @@ -29,7 +30,7 @@ private void OnTextChanged(object sender, TextChangedEventArgs e)

private void SetHasTextProperty()
{
this.AssociatedObject.TemplatedParent?.SetValue(TextBoxHelper.HasTextProperty, this.AssociatedObject.Text.Length > 0);
this.AssociatedObject.TemplatedParent?.SetCurrentValue(TextBoxHelper.HasTextProperty, BooleanBoxes.Box(this.AssociatedObject.Text.Length > 0));
}
}
}
11 changes: 6 additions & 5 deletions src/MahApps.Metro/Behaviors/PasswordBoxBindingBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Windows.Controls;
using System.Windows.Documents;
using MahApps.Metro.Controls;
using MahApps.Metro.ValueBoxes;
using Microsoft.Xaml.Behaviors;

namespace MahApps.Metro.Behaviors
Expand Down Expand Up @@ -159,16 +160,16 @@ private static readonly DependencyProperty IsChangingProperty
= DependencyProperty.RegisterAttached("IsChanging",
typeof(bool),
typeof(PasswordBoxBindingBehavior),
new UIPropertyMetadata(false));
new UIPropertyMetadata(BooleanBoxes.FalseBox));

private static bool GetIsChanging(DependencyObject obj)
private static bool GetIsChanging(UIElement element)
{
return (bool)obj.GetValue(IsChangingProperty);
return (bool)element.GetValue(IsChangingProperty);
}

private static void SetIsChanging(DependencyObject obj, bool value)
private static void SetIsChanging(UIElement element, bool value)
{
obj.SetValue(IsChangingProperty, value);
element.SetValue(IsChangingProperty, BooleanBoxes.Box(value));
}

private static readonly DependencyProperty SelectionProperty
Expand Down
9 changes: 5 additions & 4 deletions src/MahApps.Metro/Behaviors/ReloadBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using MahApps.Metro.Controls;
using MahApps.Metro.ValueBoxes;

namespace MahApps.Metro.Behaviors
{
Expand All @@ -17,7 +18,7 @@ public static readonly DependencyProperty OnDataContextChangedProperty
= DependencyProperty.RegisterAttached("OnDataContextChanged",
typeof(bool),
typeof(ReloadBehavior),
new PropertyMetadata(OnOnDataContextChanged));
new PropertyMetadata(BooleanBoxes.FalseBox, OnOnDataContextChanged));

/// <summary>
/// Helper for getting <see cref="OnDataContextChangedProperty"/> from <paramref name="element"/>.
Expand All @@ -44,7 +45,7 @@ public static bool GetOnDataContextChanged(UIElement element)
[AttachedPropertyBrowsableForType(typeof(MetroContentControl))]
public static void SetOnDataContextChanged(UIElement element, bool value)
{
element.SetValue(OnDataContextChangedProperty, value);
element.SetValue(OnDataContextChangedProperty, BooleanBoxes.Box(value));
}

private static void OnOnDataContextChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
Expand All @@ -71,7 +72,7 @@ public static readonly DependencyProperty OnSelectedTabChangedProperty
= DependencyProperty.RegisterAttached("OnSelectedTabChanged",
typeof(bool),
typeof(ReloadBehavior),
new PropertyMetadata(OnSelectedTabChanged));
new PropertyMetadata(BooleanBoxes.FalseBox, OnSelectedTabChanged));

/// <summary>
/// Helper for getting <see cref="OnSelectedTabChangedProperty"/> from <paramref name="element"/>.
Expand Down Expand Up @@ -100,7 +101,7 @@ public static bool GetOnSelectedTabChanged(UIElement element)
[AttachedPropertyBrowsableForType(typeof(TransitioningContentControl))]
public static void SetOnSelectedTabChanged(UIElement element, bool value)
{
element.SetValue(OnSelectedTabChangedProperty, value);
element.SetValue(OnSelectedTabChangedProperty, BooleanBoxes.Box(value));
}

private static void OnSelectedTabChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
Expand Down
5 changes: 3 additions & 2 deletions src/MahApps.Metro/Behaviors/TiltBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Media;
using ControlzEx.Theming;
using MahApps.Metro.Controls;
using MahApps.Metro.ValueBoxes;
using Microsoft.Xaml.Behaviors;

namespace MahApps.Metro.Behaviors
Expand All @@ -17,12 +18,12 @@ public static readonly DependencyProperty KeepDraggingProperty
= DependencyProperty.Register(nameof(KeepDragging),
typeof(bool),
typeof(TiltBehavior),
new PropertyMetadata(true));
new PropertyMetadata(BooleanBoxes.TrueBox));

public bool KeepDragging
{
get => (bool)this.GetValue(KeepDraggingProperty);
set => this.SetValue(KeepDraggingProperty, value);
set => this.SetValue(KeepDraggingProperty, BooleanBoxes.Box(value));
}

/// <summary>Identifies the <see cref="TiltFactor"/> dependency property.</summary>
Expand Down
17 changes: 9 additions & 8 deletions src/MahApps.Metro/Controls/ClipBorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using MahApps.Metro.ValueBoxes;

namespace MahApps.Metro.Controls
{
Expand All @@ -54,7 +55,7 @@ public sealed class ClipBorder : Decorator
/// BorderThickness Dependency Property
/// </summary>
public static readonly DependencyProperty BorderThicknessProperty =
DependencyProperty.Register("BorderThickness", typeof(Thickness), typeof(ClipBorder),
DependencyProperty.Register(nameof(BorderThickness), typeof(Thickness), typeof(ClipBorder),
new FrameworkPropertyMetadata(new Thickness(),
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender),
OnValidateThickness);
Expand Down Expand Up @@ -98,7 +99,7 @@ private static bool OnValidateThickness(object value)
/// Padding Dependency Property
/// </summary>
public static readonly DependencyProperty PaddingProperty =
DependencyProperty.Register("Padding", typeof(Thickness), typeof(ClipBorder),
DependencyProperty.Register(nameof(Padding), typeof(Thickness), typeof(ClipBorder),
new FrameworkPropertyMetadata(new Thickness(),
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender),
OnValidateThickness);
Expand Down Expand Up @@ -131,7 +132,7 @@ public Thickness Padding
/// CornerRadius Dependency Property
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ClipBorder),
DependencyProperty.Register(nameof(CornerRadius), typeof(CornerRadius), typeof(ClipBorder),
new FrameworkPropertyMetadata(new CornerRadius(),
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender),
OnValidateCornerRadius);
Expand Down Expand Up @@ -175,7 +176,7 @@ private static bool OnValidateCornerRadius(object value)
/// BorderBrush Dependency Property
/// </summary>
public static readonly DependencyProperty BorderBrushProperty =
DependencyProperty.Register("BorderBrush", typeof(Brush), typeof(ClipBorder),
DependencyProperty.Register(nameof(BorderBrush), typeof(Brush), typeof(ClipBorder),
new FrameworkPropertyMetadata(null,
FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.SubPropertiesDoNotAffectRender));

Expand All @@ -197,7 +198,7 @@ public Brush BorderBrush
/// Background Dependency Property
/// </summary>
public static readonly DependencyProperty BackgroundProperty =
DependencyProperty.Register("Background", typeof(Brush), typeof(ClipBorder),
DependencyProperty.Register(nameof(Background), typeof(Brush), typeof(ClipBorder),
new FrameworkPropertyMetadata(null,
FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.SubPropertiesDoNotAffectRender));

Expand All @@ -219,8 +220,8 @@ public Brush Background
/// OptimizeClipRendering Dependency Property
/// </summary>
public static readonly DependencyProperty OptimizeClipRenderingProperty =
DependencyProperty.Register("OptimizeClipRendering", typeof(bool), typeof(ClipBorder),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
DependencyProperty.Register(nameof(OptimizeClipRendering), typeof(bool), typeof(ClipBorder),
new FrameworkPropertyMetadata(BooleanBoxes.FalseBox, FrameworkPropertyMetadataOptions.AffectsRender));

/// <summary>
/// Gets or sets the OptimizeClipRendering property. This dependency property
Expand All @@ -235,7 +236,7 @@ public Brush Background
public bool OptimizeClipRendering
{
get { return (bool)GetValue(OptimizeClipRenderingProperty); }
set { SetValue(OptimizeClipRenderingProperty, value); }
set { SetValue(OptimizeClipRenderingProperty, BooleanBoxes.Box(value)); }
}

#endregion
Expand Down
5 changes: 3 additions & 2 deletions src/MahApps.Metro/Controls/ContentControlEx.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Windows;
using System.Windows.Controls;
using MahApps.Metro.ValueBoxes;

namespace MahApps.Metro.Controls
{
Expand Down Expand Up @@ -27,15 +28,15 @@ public static readonly DependencyProperty RecognizesAccessKeyProperty
= DependencyProperty.Register(nameof(RecognizesAccessKey),
typeof(bool),
typeof(ContentControlEx),
new FrameworkPropertyMetadata(false));
new FrameworkPropertyMetadata(BooleanBoxes.FalseBox));

/// <summary>
/// Determine if the inner ContentPresenter should use AccessText in its style
/// </summary>
public bool RecognizesAccessKey
{
get => (bool)this.GetValue(RecognizesAccessKeyProperty);
set => this.SetValue(RecognizesAccessKeyProperty, value);
set => this.SetValue(RecognizesAccessKeyProperty, BooleanBoxes.Box(value));
}

static ContentControlEx()
Expand Down
Loading

0 comments on commit d57ce8a

Please sign in to comment.