Skip to content

Commit e1f8971

Browse files
authored
Add filled combo box (#1706)
Fixes #1479
1 parent 6db4490 commit e1f8971

File tree

3 files changed

+439
-74
lines changed

3 files changed

+439
-74
lines changed

MainDemo.Wpf/Fields.xaml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@
362362
<StackPanel Orientation="Horizontal" Grid.Row="10" Grid.Column="4">
363363
<smtx:XamlDisplay Key="fields_22" HorizontalAlignment="Left">
364364
<TextBox Width="20"
365-
materialDesign:ValidationAssist.UsePopup="True"
366-
HorizontalAlignment="Left"
367-
ToolTip="Use a popup which can escape the bounds of the control where space is limited">
365+
materialDesign:ValidationAssist.UsePopup="True"
366+
HorizontalAlignment="Left"
367+
ToolTip="Use a popup which can escape the bounds of the control where space is limited">
368368
<TextBox.Text>
369369
<Binding Path="Name" UpdateSourceTrigger="PropertyChanged">
370370
<Binding.ValidationRules>
@@ -376,10 +376,10 @@
376376
</smtx:XamlDisplay>
377377
<smtx:XamlDisplay Key="fields_30" Grid.Row="8" Grid.Column="5" HorizontalAlignment="Left">
378378
<TextBox Width="20"
379-
materialDesign:ValidationAssist.UsePopup="True"
380-
materialDesign:ValidationAssist.PopupPlacement="Left"
381-
HorizontalAlignment="Left"
382-
ToolTip="Use a popup which can escape the bounds of the control where space is limited it can be placed in alternative positions">
379+
materialDesign:ValidationAssist.UsePopup="True"
380+
materialDesign:ValidationAssist.PopupPlacement="Left"
381+
HorizontalAlignment="Left"
382+
ToolTip="Use a popup which can escape the bounds of the control where space is limited it can be placed in alternative positions">
383383
<TextBox.Text>
384384
<Binding Path="Name2" UpdateSourceTrigger="PropertyChanged">
385385
<Binding.ValidationRules>
@@ -424,7 +424,7 @@
424424
<smtx:XamlDisplay Key="fields_25" Grid.Row="14" Grid.Column="1" Grid.RowSpan="2" Grid.ColumnSpan="3">
425425
<StackPanel>
426426
<CheckBox x:Name="MaterialDesignFilledTextFieldTextBoxEnabledComboBox"
427-
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
427+
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
428428
<TextBox Style="{StaticResource MaterialDesignFilledTextFieldTextBox}"
429429
VerticalAlignment="Top" AcceptsReturn="True" TextWrapping="Wrap" MaxWidth="400" materialDesign:HintAssist.Hint="Floating hint in a box"
430430
IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignFilledTextFieldTextBoxEnabledComboBox}" />
@@ -446,19 +446,35 @@
446446
<smtx:XamlDisplay Key="fields_28" Grid.Row="17" Grid.Column="1" Grid.ColumnSpan="3">
447447
<StackPanel>
448448
<CheckBox x:Name="MaterialDesignFilledPasswordFieldPasswordBoxEnabledComboBox"
449-
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
449+
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
450450
<PasswordBox Style="{StaticResource MaterialDesignFilledPasswordFieldPasswordBox}"
451451
VerticalAlignment="Top"
452452
IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignFilledPasswordFieldPasswordBoxEnabledComboBox}"
453453
materialDesign:HintAssist.Hint="Password" />
454454
</StackPanel>
455455
</smtx:XamlDisplay>
456456

457+
<TextBlock Grid.Row="18" Grid.Column="1" Grid.ColumnSpan="3" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="0,32,0,16">Filled ComboBox</TextBlock>
458+
<smtx:XamlDisplay Key="fields_filled_combobox" Grid.Row="19" Grid.Column="1" Grid.ColumnSpan="3">
459+
<StackPanel>
460+
<CheckBox x:Name="MaterialDesignFilledComboBoxEnabledComboBox"
461+
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
462+
<ComboBox Style="{StaticResource MaterialDesignFilledComboBox}"
463+
VerticalAlignment="Top"
464+
IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignFilledComboBoxEnabledComboBox}"
465+
materialDesign:HintAssist.Hint="Some item">
466+
<ComboBoxItem Content="Item 1" />
467+
<ComboBoxItem Content="Item 2" />
468+
<ComboBoxItem Content="Item 3" />
469+
</ComboBox>
470+
</StackPanel>
471+
</smtx:XamlDisplay>
472+
457473
<TextBlock Grid.Row="18" Grid.Column="4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="32,32,0,16">Outlined password field</TextBlock>
458474
<smtx:XamlDisplay Key="fields_29" Grid.Row="19" Grid.Column="4" Margin="32,0,0,0">
459475
<StackPanel>
460476
<CheckBox x:Name="MaterialDesignOutlinedPasswordFieldPasswordBoxEnabledComboBox"
461-
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
477+
IsChecked="True" Margin="0,0,0,8">Enabled</CheckBox>
462478
<PasswordBox Style="{StaticResource MaterialDesignOutlinedPasswordFieldPasswordBox}"
463479
VerticalAlignment="Top"
464480
IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignOutlinedPasswordFieldPasswordBoxEnabledComboBox}"

MaterialDesignThemes.Wpf/ComboBoxPopup.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,45 @@ public bool ClassicMode
170170

171171
#endregion
172172

173+
public static readonly DependencyProperty CornerRadiusProperty
174+
= DependencyProperty.Register(
175+
nameof(CornerRadius),
176+
typeof(CornerRadius),
177+
typeof(ComboBoxPopup),
178+
new FrameworkPropertyMetadata(default(CornerRadius)));
179+
180+
public CornerRadius CornerRadius
181+
{
182+
get { return (CornerRadius)GetValue(CornerRadiusProperty); }
183+
set { SetValue(CornerRadiusProperty, value); }
184+
}
185+
186+
public static readonly DependencyProperty ContentMarginProperty
187+
= DependencyProperty.Register(
188+
nameof(ContentMargin),
189+
typeof(Thickness),
190+
typeof(ComboBoxPopup),
191+
new FrameworkPropertyMetadata(default(Thickness)));
192+
193+
public Thickness ContentMargin
194+
{
195+
get { return (Thickness)GetValue(ContentMarginProperty); }
196+
set { SetValue(ContentMarginProperty, value); }
197+
}
198+
199+
public static readonly DependencyProperty ContentMinWidthProperty
200+
= DependencyProperty.Register(
201+
nameof(ContentMinWidth),
202+
typeof(double),
203+
typeof(ComboBoxPopup),
204+
new FrameworkPropertyMetadata(default(double)));
205+
206+
public double ContentMinWidth
207+
{
208+
get { return (double)GetValue(ContentMinWidthProperty); }
209+
set { SetValue(ContentMinWidthProperty, value); }
210+
}
211+
173212
public ComboBoxPopup()
174213
{
175214
CustomPopupPlacementCallback = ComboBoxCustomPopupPlacementCallback;

0 commit comments

Comments
 (0)