diff --git a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/ComboBoxHelper.cs b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/ComboBoxHelper.cs
index 0dfc6f7b29..1f28f0b166 100644
--- a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/ComboBoxHelper.cs
+++ b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/Helper/ComboBoxHelper.cs
@@ -1,45 +1,55 @@
-using System.Windows;
+using System.ComponentModel;
+using System.Windows;
using System.Windows.Controls;
namespace MahApps.Metro.Controls
{
- using System.ComponentModel;
-
///
- /// A helper class that provides various attached properties for the ComboBox control.
- ///
+ /// A helper class that provides various attached properties for the control.
///
public class ComboBoxHelper
{
- public static readonly DependencyProperty EnableVirtualizationWithGroupingProperty = DependencyProperty.RegisterAttached("EnableVirtualizationWithGrouping", typeof(bool), typeof(ComboBoxHelper), new FrameworkPropertyMetadata(false, EnableVirtualizationWithGroupingPropertyChangedCallback));
+ public static readonly DependencyProperty EnableVirtualizationWithGroupingProperty
+ = DependencyProperty.RegisterAttached("EnableVirtualizationWithGrouping",
+ typeof(bool),
+ typeof(ComboBoxHelper),
+ new FrameworkPropertyMetadata(false, OnEnableVirtualizationWithGroupingChanged));
- private static void EnableVirtualizationWithGroupingPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
+ private static void OnEnableVirtualizationWithGroupingChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
var comboBox = dependencyObject as ComboBox;
if (comboBox != null && e.NewValue != e.OldValue)
{
#if NET4_5
- comboBox.SetValue(VirtualizingStackPanel.IsVirtualizingProperty, e.NewValue);
- comboBox.SetValue(VirtualizingPanel.IsVirtualizingWhenGroupingProperty, e.NewValue);
- comboBox.SetValue(ScrollViewer.CanContentScrollProperty, e.NewValue);
+ comboBox.SetCurrentValue(VirtualizingStackPanel.IsVirtualizingProperty, e.NewValue);
+ comboBox.SetCurrentValue(VirtualizingPanel.IsVirtualizingWhenGroupingProperty, e.NewValue);
+ comboBox.SetCurrentValue(ScrollViewer.CanContentScrollProperty, e.NewValue);
#endif
}
}
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(ComboBox))]
public static void SetEnableVirtualizationWithGrouping(DependencyObject obj, bool value)
{
obj.SetValue(EnableVirtualizationWithGroupingProperty, value);
}
[Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(ComboBox))]
public static bool GetEnableVirtualizationWithGrouping(DependencyObject obj)
{
return (bool)obj.GetValue(EnableVirtualizationWithGroupingProperty);
}
- public static readonly DependencyProperty MaxLengthProperty = DependencyProperty.RegisterAttached("MaxLength", typeof(int), typeof(ComboBoxHelper), new FrameworkPropertyMetadata(0), new ValidateValueCallback(MaxLengthValidateValue));
+ public static readonly DependencyProperty MaxLengthProperty
+ = DependencyProperty.RegisterAttached("MaxLength",
+ typeof(int),
+ typeof(ComboBoxHelper),
+ new FrameworkPropertyMetadata(0),
+ ValidateMaxLength);
- private static bool MaxLengthValidateValue(object value)
+ private static bool ValidateMaxLength(object value)
{
return ((int)value) >= 0;
}
@@ -57,14 +67,21 @@ public static int GetMaxLength(UIElement obj)
///
/// Sets the Maximum number of characters the TextBox can accept.
///
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(ComboBox))]
public static void SetMaxLength(UIElement obj, int value)
{
obj.SetValue(MaxLengthProperty, value);
}
- public static readonly DependencyProperty CharacterCasingProperty = DependencyProperty.RegisterAttached("CharacterCasing", typeof(CharacterCasing), typeof(ComboBoxHelper), new FrameworkPropertyMetadata(CharacterCasing.Normal), new ValidateValueCallback(CharacterCasingValidateValue));
+ public static readonly DependencyProperty CharacterCasingProperty
+ = DependencyProperty.RegisterAttached("CharacterCasing",
+ typeof(CharacterCasing),
+ typeof(ComboBoxHelper),
+ new FrameworkPropertyMetadata(CharacterCasing.Normal),
+ ValidateCharacterCasing);
- private static bool CharacterCasingValidateValue(object value)
+ private static bool ValidateCharacterCasing(object value)
{
return (CharacterCasing.Normal <= (CharacterCasing)value && (CharacterCasing)value <= CharacterCasing.Upper);
}
@@ -82,9 +99,11 @@ public static CharacterCasing GetCharacterCasing(UIElement obj)
///
/// Sets the Character casing of the TextBox.
///
+ [Category(AppName.MahApps)]
+ [AttachedPropertyBrowsableForType(typeof(ComboBox))]
public static void SetCharacterCasing(UIElement obj, CharacterCasing value)
{
obj.SetValue(CharacterCasingProperty, value);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/RangeSlider.cs b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/RangeSlider.cs
index 97083c06e8..8dabf2ffc3 100644
--- a/src/MahApps.Metro/MahApps.Metro.Shared/Controls/RangeSlider.cs
+++ b/src/MahApps.Metro/MahApps.Metro.Shared/Controls/RangeSlider.cs
@@ -1938,16 +1938,6 @@ private void RelocateAutoToolTip()
_autoToolTip.HorizontalOffset = offset;
}
- private static bool IsValidDoubleValue(object value)
- {
- return value is double && IsValidDouble((double)value);
- }
-
- private static bool IsValidDouble(double d)
- {
- return !double.IsNaN(d) && !double.IsInfinity(d);
- }
-
//CHeck if two doubles approximately equals
private bool ApproximatelyEquals(double value1, double value2)
{
@@ -2024,6 +2014,16 @@ private CustomPopupPlacement[] PopupPlacementCallback(Size popupSize, Size targe
#region Validation methods
+ private static bool IsValidDoubleValue(object value)
+ {
+ return value is double && IsValidDouble((double)value);
+ }
+
+ private static bool IsValidDouble(double d)
+ {
+ return !double.IsNaN(d) && !double.IsInfinity(d);
+ }
+
private static bool IsValidPrecision(object value)
{
return ((Int32)value >= 0);
@@ -2031,13 +2031,7 @@ private static bool IsValidPrecision(object value)
private static bool IsValidMinRange(object value)
{
- double d = (double)value;
- if (!Double.IsNaN(d))
- {
- return d >= 0d || !double.IsInfinity(d);
- }
-
- return false;
+ return value is double && IsValidDouble((double)value) && (double)value >= 0d;
}
#endregion
diff --git a/src/MahApps.Metro/MahApps.Metro/Properties/AssemblyInfo.cs b/src/MahApps.Metro/MahApps.Metro/Properties/AssemblyInfo.cs
index 6b538c9fd4..a1b83ec83a 100644
--- a/src/MahApps.Metro/MahApps.Metro/Properties/AssemblyInfo.cs
+++ b/src/MahApps.Metro/MahApps.Metro/Properties/AssemblyInfo.cs
@@ -19,3 +19,6 @@
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyInformationalVersion("1.6.0.0")]
[assembly: AssemblyProduct("MahApps.Metro 1.6.0")]
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0006:Name of CoerceValueCallback should match registered name.")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("WpfAnalyzers.DependencyProperty", "WPF0007:Name of ValidateValueCallback should match registered name.")]
\ No newline at end of file