Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5923051
Initial work of respecting TextBox.Height - only done for TextBox so far
nicolaihenriksen Apr 25, 2023
ee18094
Aligning prefix/suffix texts
nicolaihenriksen Apr 27, 2023
860bcff
PasswordBox respects VerticalContentAlignment
nicolaihenriksen Apr 27, 2023
18d06d9
Fixes hint floating position for default offset
nicolaihenriksen May 1, 2023
539f009
DatePicker now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
0818e7b
TimePicker now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
c74f17f
Renamed element to match content
nicolaihenriksen May 1, 2023
31145a0
PasswordBox trailing icons/buttons now respect VerticalContentAlignment
nicolaihenriksen May 1, 2023
8c482ce
ComboBox clear button now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
00e4d34
ComboBox toggle button now respects VerticalContentAlignment
nicolaihenriksen May 1, 2023
bf2dedc
Improved 'Smart Hint' demo app page
nicolaihenriksen May 1, 2023
91f653c
Added FontSize to 'Smart Hint' demo app page
nicolaihenriksen May 1, 2023
2edf542
Change default VerticalContentAlignment of ComboBox to Center
nicolaihenriksen May 2, 2023
13dcc23
Apply red color to FontSize in 'Smart Hint' demo page
nicolaihenriksen May 2, 2023
9570007
Use FontFamily from "hint" as input to floating offset converter
nicolaihenriksen May 2, 2023
0580e60
Add support for controlling FontFamily in 'Smart Hint' demo page
nicolaihenriksen May 2, 2023
7b2a333
Add comment in demo app page regarding ShowMeTheXaml
nicolaihenriksen May 2, 2023
2d9e411
Fix typo
nicolaihenriksen May 2, 2023
5500491
Fix for broken UI tests for DatePicker and TimePicker
nicolaihenriksen May 2, 2023
884d312
Fix broken UI tests for PasswordBox
nicolaihenriksen May 2, 2023
91bd6a7
Apply same visibility fix for TextBox as was done to PasswordBox, etc.
nicolaihenriksen May 2, 2023
76d6f94
Align ComboBox prefix/suffix text margin and visibility with other ctrls
nicolaihenriksen May 2, 2023
b717ad5
Use HelperTextStyle in ComboBox, DatePicker, and TimePicker
nicolaihenriksen May 2, 2023
bef99f5
Set default VerticalContentAlignment=Center for Date- and TimePicker
nicolaihenriksen May 2, 2023
95d9075
Fixed failing unit tests for FloatingHintTransformConverter
nicolaihenriksen May 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved 'Smart Hint' demo app page
  • Loading branch information
nicolaihenriksen committed May 1, 2023
commit bf2dedc681c1a71bd63e8a24ba5001494b5ccf0b
6 changes: 4 additions & 2 deletions MainDemo.Wpf/Domain/SmartHintViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace MaterialDesignDemo.Domain;

internal class SmartHintViewModel : ViewModelBase
{
public static Point DefaultFloatingOffset { get; } = new(0, -16);

private bool _floatHint = true;
private FloatingHintHorizontalAlignment _selectedAlignment = FloatingHintHorizontalAlignment.Inherit;
private double _selectedFloatingScale = 0.75;
Expand All @@ -12,7 +14,7 @@ internal class SmartHintViewModel : ViewModelBase
private bool _showTrailingIcon = true;
private string _hintText = "Hint text";
private string _helperText = "Helper text";
private Point _selectedFloatingOffset = new(0, -16);
private Point _selectedFloatingOffset = DefaultFloatingOffset;
private bool _applyCustomPadding;
private Thickness _selectedCustomPadding = new(5);
private double _selectedCustomHeight = double.NaN;
Expand All @@ -24,7 +26,7 @@ internal class SmartHintViewModel : ViewModelBase

public IEnumerable<FloatingHintHorizontalAlignment> HorizontalAlignmentOptions { get; } = Enum.GetValues(typeof(FloatingHintHorizontalAlignment)).OfType<FloatingHintHorizontalAlignment>();
public IEnumerable<double> FloatingScaleOptions { get; } = new[] {0.25, 0.5, 0.75, 1.0};
public IEnumerable<Point> FloatingOffsetOptions { get; } = new[] { new Point(0, -16), new Point(0, 16), new Point(16, 16), new Point(-16, -16), new Point(0, -40) };
public IEnumerable<Point> FloatingOffsetOptions { get; } = new[] { DefaultFloatingOffset, new Point(0, -25), new Point(16, -16), new Point(-16, -16), new Point(0, -50) };
public IEnumerable<string> ComboBoxOptions { get; } = new[] {"Option 1", "Option 2", "Option 3"};
public IEnumerable<Thickness> CustomPaddingOptions { get; } = new [] { new Thickness(0), new Thickness(5), new Thickness(10), new Thickness(15) };
public IEnumerable<double> CustomHeightOptions { get; } = new[] { double.NaN, 50, 75, 100 };
Expand Down
17 changes: 14 additions & 3 deletions MainDemo.Wpf/SmartHint.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:domain="clr-namespace:MaterialDesignDemo.Domain"
xmlns:local="clr-namespace:MaterialDesignDemo"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
x:Name="_root"
d:DataContext="{d:DesignInstance domain:SmartHintViewModel, IsDesignTimeCreatable=False}"
Expand All @@ -31,6 +32,16 @@
</Style>
<materialDesign:PackIconKind x:Key="LeadingIcon">Github</materialDesign:PackIconKind>
<materialDesign:PackIconKind x:Key="TrailingIcon">Fungus</materialDesign:PackIconKind>

<local:DoubleOptionToStringConverter x:Key="DoubleOptionToStringConverter" DefaultValue="{x:Static system:Double.NaN}" />
<DataTemplate x:Key="CustomHeightTemplate" DataType="{x:Type system:Double}">
<TextBlock Text="{Binding Converter={StaticResource DoubleOptionToStringConverter}}" />
</DataTemplate>

<local:PointOptionToStringConverter x:Key="FloatingOffsetOptionToStringConverter" DefaultValue="{x:Static domain:SmartHintViewModel.DefaultFloatingOffset}" />
<DataTemplate x:Key="FloatingOffsetTemplate">
<TextBlock Text="{Binding Converter={StaticResource FloatingOffsetOptionToStringConverter}}" />
</DataTemplate>
</Grid.Resources>

<Grid.RowDefinitions>
Expand All @@ -49,7 +60,7 @@
<TextBlock Text="FloatingScale:" VerticalAlignment="Center" Margin="20,0,0,0" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding FloatingScaleOptions}" SelectedItem="{Binding SelectedFloatingScale, Mode=TwoWay}" ItemStringFormat="F2" />
<TextBlock Text="FloatingOffset:" VerticalAlignment="Center" Margin="20,0,0,0" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding FloatingOffsetOptions}" SelectedItem="{Binding SelectedFloatingOffset, Mode=TwoWay}" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding FloatingOffsetOptions}" SelectedItem="{Binding SelectedFloatingOffset, Mode=TwoWay}" ItemTemplate="{StaticResource FloatingOffsetTemplate}" />
<CheckBox Content="HasClearButton" IsChecked="{Binding ShowClearButton}" Margin="20,0,0,0" />
<CheckBox Content="HasErrors" IsChecked="False" Checked="HasErrors_OnToggled" Unchecked="HasErrors_OnToggled" Margin="20,0,0,0" />
</StackPanel>
Expand All @@ -71,8 +82,8 @@
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="CustomPaddingCheckBox" Content="Custom Padding" IsChecked="{Binding ApplyCustomPadding}" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding CustomPaddingOptions}" SelectedItem="{Binding SelectedCustomPadding, Mode=TwoWay}" IsEnabled="{Binding ElementName=CustomPaddingCheckBox, Path=IsChecked}" />
<TextBlock Text="Custom Height:" VerticalAlignment="Center" Margin="20,0,0,0" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding CustomHeightOptions}" SelectedItem="{Binding SelectedCustomHeight, Mode=TwoWay}" />
<TextBlock Text="Height:" VerticalAlignment="Center" Margin="20,0,0,0" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding CustomHeightOptions}" SelectedItem="{Binding SelectedCustomHeight, Mode=TwoWay}" ItemTemplate="{StaticResource CustomHeightTemplate}"/>
<TextBlock Text="VerticalContentAlignment:" VerticalAlignment="Center" Margin="20,0,0,0" />
<ComboBox VerticalAlignment="Center" Margin="5,0,0,0" ItemsSource="{Binding VerticalAlignmentOptions}" SelectedItem="{Binding SelectedVerticalAlignment, Mode=TwoWay}" />
<TextBox Text="{Binding PrefixText, UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="Prefix text" materialDesign:TextFieldAssist.HasClearButton="True" Margin="20,0,0,0" Width="200" MaxLength="3" />
Expand Down
23 changes: 23 additions & 0 deletions MainDemo.Wpf/SmartHint.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,26 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}

internal abstract class OptionToStringConverter<TOptionType> : IValueConverter where TOptionType : notnull
{
public TOptionType? DefaultValue { get; set; }

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> Equals(value, DefaultValue) ? "Default" : ToString((TOptionType)value!, culture);

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotImplementedException();

protected abstract string ToString(TOptionType? value, CultureInfo culture);
}

internal class DoubleOptionToStringConverter : OptionToStringConverter<double>
{
protected override string ToString(double value, CultureInfo culture) => value.ToString(culture);
}

internal class PointOptionToStringConverter : OptionToStringConverter<Point>
{
protected override string ToString(Point value, CultureInfo culture) => value.ToString(culture);
}