-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added BorderThickness attached DP for outlined date/time pickers (#2805)
* Added BorderThickness attached DP for outlined date/time pickers * Added UI tests * Fixed typos in code comment * Increased delay in tests Tests are running green locally, so I presume it has something to do with the delay being too short * Fixed UI tests Initial mouse position was on the pickers, so I added a dummy button to initially move the mouse position away from the pickers. * Updated UI tests to test validation error scenario Ideally I would like XAMLTest to allow me to set a ValidationError "on the fly" if possible. For now, tests are updated with a real ValidationRule and invalid values are set to provoke the validation error.
- Loading branch information
1 parent
4cd847f
commit e133232
Showing
10 changed files
with
346 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
MaterialDesignThemes.Wpf/Converters/OutlinedDateTimePickerActiveBorderThicknessConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace MaterialDesignThemes.Wpf.Converters; | ||
|
||
public class OutlinedDateTimePickerActiveBorderThicknessConverter : IMultiValueConverter | ||
{ | ||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (values.Length == 2 | ||
&& values[0] is Thickness baseThickness | ||
&& values[1] is Thickness thicknessToSubtract) | ||
{ | ||
var thickness = new Thickness(baseThickness.Left - thicknessToSubtract.Left, | ||
baseThickness.Top - thicknessToSubtract.Top, | ||
baseThickness.Right - thicknessToSubtract.Right, | ||
baseThickness.Bottom - thicknessToSubtract.Bottom); | ||
return thickness; | ||
} | ||
return default(Thickness); | ||
} | ||
|
||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace MaterialDesignThemes.Wpf; | ||
|
||
public static class DatePickerAssist | ||
{ | ||
private static Thickness DefaultOutlinedBorderInactiveThickness { get; } = new(1); | ||
private static Thickness DefaultOutlinedBorderActiveThickness { get; } = new(2); | ||
|
||
public static readonly DependencyProperty OutlinedBorderInactiveThicknessProperty = DependencyProperty.RegisterAttached( | ||
"OutlinedBorderInactiveThickness", typeof(Thickness), typeof(DatePickerAssist), new FrameworkPropertyMetadata(DefaultOutlinedBorderInactiveThickness, FrameworkPropertyMetadataOptions.Inherits)); | ||
|
||
public static void SetOutlinedBorderInactiveThickness(DependencyObject element, Thickness value) | ||
{ | ||
element.SetValue(OutlinedBorderInactiveThicknessProperty, value); | ||
} | ||
|
||
public static Thickness GetOutlinedBorderInactiveThickness(DependencyObject element) | ||
{ | ||
return (Thickness) element.GetValue(OutlinedBorderInactiveThicknessProperty); | ||
} | ||
|
||
public static readonly DependencyProperty OutlinedBorderActiveThicknessProperty = DependencyProperty.RegisterAttached( | ||
"OutlinedBorderActiveThickness", typeof(Thickness), typeof(DatePickerAssist), new FrameworkPropertyMetadata(DefaultOutlinedBorderActiveThickness, FrameworkPropertyMetadataOptions.Inherits)); | ||
|
||
public static void SetOutlinedBorderActiveThickness(DependencyObject element, Thickness value) | ||
{ | ||
element.SetValue(OutlinedBorderActiveThicknessProperty, value); | ||
} | ||
|
||
public static Thickness GetOutlinedBorderActiveThickness(DependencyObject element) | ||
{ | ||
return (Thickness) element.GetValue(OutlinedBorderActiveThicknessProperty); | ||
} | ||
} |
Oops, something went wrong.