-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added BorderThickness attached DP for outlined date/time pickers #2805
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e508212
Added BorderThickness attached DP for outlined date/time pickers
nicolaihenriksen 388664f
Added UI tests
nicolaihenriksen c23157b
Fixed typos in code comment
nicolaihenriksen b1b6b9e
Increased delay in tests
nicolaihenriksen a199cda
Fixed UI tests
nicolaihenriksen fca2390
Updated UI tests to test validation error scenario
nicolaihenriksen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good request. I will have to look into what that API could look like. I typically have done that by building out a custom control in the test project (as this then supports things like code behind, view models, etc). But I can certainly see a desire to not have to jump through all of those hoops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! As mentioned in the PR, I already have a proof-of-concept PR in the XAMLTest library with one approach to adding this type of functionality. Looking forward to seeing how you would approach it.