Skip to content

Commit 42435cf

Browse files
authored
More work on the filled combo box to bring it in closer to spec. (#1715)
1 parent 96bae97 commit 42435cf

File tree

5 files changed

+40
-32
lines changed

5 files changed

+40
-32
lines changed

MainDemo.Wpf/Fields.xaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,17 @@
457457
<TextBlock Grid.Row="18" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="0,32,0,16">Filled ComboBox</TextBlock>
458458
<smtx:XamlDisplay Key="fields_filled_combobox" Grid.Row="19" Grid.Column="1" Grid.ColumnSpan="3">
459459
<StackPanel>
460-
<CheckBox x:Name="MaterialDesignFilledComboBoxEnabledComboBox"
461-
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
462-
<ComboBox Style="{StaticResource MaterialDesignFilledComboBox}"
463-
VerticalAlignment="Top"
460+
<Grid>
461+
<Grid.ColumnDefinitions>
462+
<ColumnDefinition />
463+
<ColumnDefinition />
464+
</Grid.ColumnDefinitions>
465+
<CheckBox x:Name="MaterialDesignFilledComboBoxEnabledComboBox"
466+
IsChecked="True" Margin="0,0,0,8" Content="Enabled"/>
467+
<Button Content="Clear" Style="{StaticResource MaterialDesignFlatButton}" HorizontalAlignment="Right"
468+
Grid.Column="1" Click="ClearFilledComboBox_Click"/>
469+
</Grid>
470+
<ComboBox Style="{StaticResource MaterialDesignFilledComboBox}" x:Name="FilledComboBx"
464471
IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignFilledComboBoxEnabledComboBox}"
465472
materialDesign:HintAssist.Hint="Some item">
466473
<ComboBoxItem Content="Item 1" />

MainDemo.Wpf/Fields.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs
2020
{
2121
Link.OpenInBrowser(e.Uri.AbsoluteUri);
2222
}
23+
24+
private void ClearFilledComboBox_Click(object sender, System.Windows.RoutedEventArgs e)
25+
{
26+
FilledComboBx.SelectedItem = null;
27+
}
2328
}
2429
}

MaterialDesignThemes.Wpf/SmartHint.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ static SmartHint()
136136
DefaultStyleKeyProperty.OverrideMetadata(typeof(SmartHint), new FrameworkPropertyMetadata(typeof(SmartHint)));
137137
}
138138

139-
public SmartHint()
140-
{
141-
IsHitTestVisible = false;
142-
HorizontalAlignment = HorizontalAlignment.Left;
143-
VerticalAlignment = VerticalAlignment.Top;
144-
}
145-
146139
private static void HintProxyPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
147140
{
148141
var smartHint = dependencyObject as SmartHint;

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@
738738
CornerRadius="{Binding Path=(wpf:TextFieldAssist.TextFieldCornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
739739
Background="{DynamicResource MaterialDesignTextFieldBoxHoverBackground}"
740740
BorderThickness="1"
741-
Padding="0,8,0,0"
742741
SnapsToDevicePixels="True">
743742
<Grid x:Name="InnerRoot">
744743
<Grid.ColumnDefinitions>
@@ -753,16 +752,16 @@
753752
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
754753
Style="{StaticResource MaterialDesignComboBoxToggleButton}"
755754
Padding="{TemplateBinding Padding}"/>
756-
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
757-
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
758-
Margin="{TemplateBinding Padding}"
755+
<Grid Margin="{TemplateBinding Padding}"
759756
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
760757
UseLayoutRounding="{TemplateBinding UseLayoutRounding}">
761758
<Grid.ColumnDefinitions>
762759
<ColumnDefinition Width="*"/>
763760
<ColumnDefinition Width="Auto"/>
764761
</Grid.ColumnDefinitions>
765-
<Grid x:Name="InputRoot">
762+
<Grid x:Name="InputRoot"
763+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
764+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
766765
<ContentPresenter x:Name="contentPresenter"
767766
Content="{TemplateBinding SelectionBoxItem}"
768767
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
@@ -776,18 +775,19 @@
776775
Style="{StaticResource MaterialDesignComboBoxEditableTextBox}"
777776
CaretBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderBrush}"
778777
Visibility="Collapsed" />
779-
780-
<wpf:SmartHint x:Name="Hint"
781-
HintProxy="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:HintProxyFabricConverter.Instance}}"
782-
FontSize="{TemplateBinding FontSize}"
783-
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
784-
UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
785-
UseFloating="{Binding Path=(wpf:HintAssist.IsFloating), RelativeSource={RelativeSource TemplatedParent}}"
786-
FloatingScale="{Binding Path=(wpf:HintAssist.FloatingScale), RelativeSource={RelativeSource TemplatedParent}}"
787-
FloatingOffset="{Binding Path=(wpf:HintAssist.FloatingOffset), RelativeSource={RelativeSource TemplatedParent}}"
788-
HintOpacity="{Binding Path=(wpf:HintAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}"
789-
Hint="{TemplateBinding wpf:HintAssist.Hint}" />
790778
</Grid>
779+
<wpf:SmartHint x:Name="Hint"
780+
HintProxy="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:HintProxyFabricConverter.Instance}}"
781+
FontSize="{TemplateBinding FontSize}"
782+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
783+
UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
784+
UseFloating="{Binding Path=(wpf:HintAssist.IsFloating), RelativeSource={RelativeSource TemplatedParent}}"
785+
FloatingScale="{Binding Path=(wpf:HintAssist.FloatingScale), RelativeSource={RelativeSource TemplatedParent}}"
786+
FloatingOffset="{Binding Path=(wpf:HintAssist.FloatingOffset), RelativeSource={RelativeSource TemplatedParent}}"
787+
HintOpacity="{Binding Path=(wpf:HintAssist.HintOpacity), RelativeSource={RelativeSource TemplatedParent}}"
788+
Hint="{TemplateBinding wpf:HintAssist.Hint}"
789+
VerticalAlignment="Stretch"
790+
VerticalContentAlignment="Center"/>
791791
<StackPanel Orientation="Horizontal" Grid.Column="1" VerticalAlignment="Top">
792792
<TextBlock
793793
FontSize="{TemplateBinding FontSize}"
@@ -877,7 +877,7 @@
877877
<Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
878878
</Trigger>
879879
<Trigger Property="wpf:HintAssist.IsFloating" Value="True">
880-
<Setter TargetName="InnerRoot" Property="Margin" Value="0 12 0 0" />
880+
<Setter TargetName="InputRoot" Property="Margin" Value="0 16 0 0" />
881881
</Trigger>
882882
<MultiTrigger>
883883
<MultiTrigger.Conditions>
@@ -1075,9 +1075,11 @@
10751075
<Setter Property="wpf:TextFieldAssist.TextFieldCornerRadius" Value="4,4,0,0" />
10761076
<Setter Property="wpf:TextFieldAssist.UnderlineBrush" Value="{DynamicResource PrimaryHueMidBrush}" />
10771077
<Setter Property="wpf:HintAssist.IsFloating" Value="True" />
1078+
<Setter Property="wpf:HintAssist.FloatingOffset" Value="0,-8" />
10781079
<Setter Property="wpf:ComboBoxAssist.ShowSelectedItem" Value="False" />
1079-
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
1080-
<Setter Property="Padding" Value="8,4,8,6" />
1080+
<Setter Property="VerticalContentAlignment" Value="Stretch" />
1081+
<Setter Property="VerticalAlignment" Value="Stretch" />
1082+
<Setter Property="Padding" Value="12,8,8,8" />
10811083
<Setter Property="Template" Value="{StaticResource MaterialDesignFilledComboBoxTemplate}" />
10821084
</Style>
10831085

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.SmartHint.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
<Style TargetType="{x:Type wpf:SmartHint}">
1515
<Setter Property="HorizontalAlignment" Value="Left"/>
16-
<Setter Property="VerticalAlignment" Value="Bottom"/>
16+
<Setter Property="VerticalAlignment" Value="Top"/>
1717
<Setter Property="HorizontalContentAlignment" Value="Left"/>
1818
<Setter Property="VerticalContentAlignment" Value="Bottom"/>
1919
<Setter Property="IsTabStop" Value="False"/>
20+
<Setter Property="IsHitTestVisible" Value="False" />
2021
<Setter Property="Template">
2122
<Setter.Value>
2223
<ControlTemplate TargetType="{x:Type wpf:SmartHint}">
@@ -127,7 +128,7 @@
127128
Opacity="{TemplateBinding HintOpacity}"
128129
IsHitTestVisible="False"
129130
IsTabStop="False"
130-
RenderTransformOrigin="0,1">
131+
RenderTransformOrigin="0,0">
131132
<ContentControl.Tag>
132133
<system:Double>0.0</system:Double>
133134
</ContentControl.Tag>

0 commit comments

Comments
 (0)