Skip to content

Commit bb65708

Browse files
committed
Move ComoboBoxPopup's constants into XAML
1 parent abc0be2 commit bb65708

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

MaterialDesignThemes.Wpf/ComboBoxPopup.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ namespace MaterialDesignThemes.Wpf
1212
{
1313
public class ComboBoxPopup : Popup
1414
{
15-
public const double ContentPresenterExtend = 4;
16-
public const double TopBottomMargin = 8;
17-
public const double LeftRightMargin = 32;
18-
1915
public static readonly DependencyProperty UpContentTemplateProperty
2016
= DependencyProperty.Register(nameof(UpContentTemplate),
2117
typeof(ControlTemplate),

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<converters:TextFieldHintVisibilityConverter x:Key="TextFieldHintVisibilityConverter" IsNotEmptyValue="Collapsed" />
1313
<converters:MathConverter x:Key="MathAddConverter" Operation="Add" />
1414
<converters:BrushRoundConverter x:Key="BrushRoundConverter" />
15+
16+
<system:Double x:Key="PopupContentPresenterExtend">4</system:Double>
17+
<system:Double x:Key="PopupTopBottomMargin">8</system:Double>
18+
<system:Double x:Key="PopupLeftRightMargin">16</system:Double>
1519

1620
<Style x:Key="FocusVisual">
1721
<Setter Property="Control.Template">
@@ -26,11 +30,9 @@
2630
</Setter.Value>
2731
</Setter>
2832
</Style>
29-
30-
<system:Double x:Key="PopupLeftRightMargin">16</system:Double>
3133

3234
<ControlTemplate x:Key="PopupContentUpTemplate" TargetType="ContentControl">
33-
<Grid MinWidth="{Binding ElementName=templateRoot, Path=ActualWidth, Converter={StaticResource MathAddConverter}, ConverterParameter={x:Static wpf:ComboBoxPopup.LeftRightMargin}}"
35+
<Grid MinWidth="{Binding ElementName=templateRoot, Path=ActualWidth, Converter={StaticResource MathAddConverter}, ConverterParameter=32}"
3436
Margin="6">
3537
<Grid.RowDefinitions>
3638
<RowDefinition Height="*" />
@@ -54,11 +56,11 @@
5456
<Border Grid.Row="0"
5557
CornerRadius="2 2 0 0"
5658
Background="{Binding ElementName=PART_Popup, Path=Background}"
57-
Height="{x:Static wpf:ComboBoxPopup.TopBottomMargin}"/>
59+
Height="{StaticResource PopupTopBottomMargin}"/>
5860
<ContentPresenter Grid.Row="1"/>
5961
<Border Grid.Row="2"
6062
Background="{Binding ElementName=PART_Popup, Path=Background}"
61-
Height="{x:Static wpf:ComboBoxPopup.ContentPresenterExtend}"/>
63+
Height="{StaticResource PopupContentPresenterExtend}"/>
6264

6365
<Grid Grid.Row="3">
6466
<Grid.ColumnDefinitions>
@@ -79,14 +81,14 @@
7981

8082
<Border Grid.Row="4"
8183
CornerRadius="0 0 2 2"
82-
Height="{x:Static wpf:ComboBoxPopup.TopBottomMargin}"
84+
Height="{StaticResource PopupTopBottomMargin}"
8385
Background="{Binding ElementName=PART_Popup, Path=Background}" />
8486
</Grid>
8587
</Grid>
8688
</ControlTemplate>
8789

8890
<ControlTemplate x:Key="PopupContentDownTemplate" TargetType="ContentControl">
89-
<Grid MinWidth="{Binding ElementName=templateRoot, Path=ActualWidth, Converter={StaticResource MathAddConverter}, ConverterParameter={x:Static wpf:ComboBoxPopup.LeftRightMargin}}"
91+
<Grid MinWidth="{Binding ElementName=templateRoot, Path=ActualWidth, Converter={StaticResource MathAddConverter}, ConverterParameter=32}"
9092
Margin="6">
9193
<Grid.RowDefinitions>
9294
<RowDefinition Height="*" />
@@ -111,7 +113,7 @@
111113
<Border Grid.Row="0"
112114
CornerRadius="2 2 0 0"
113115
Background="{Binding ElementName=PART_Popup, Path=Background}"
114-
Height="{x:Static wpf:ComboBoxPopup.TopBottomMargin}"/>
116+
Height="{StaticResource PopupTopBottomMargin}"/>
115117

116118
<Grid Grid.Row="1">
117119
<Grid.ColumnDefinitions>
@@ -134,20 +136,20 @@
134136

135137
<Border Grid.Row="2"
136138
Background="{Binding ElementName=PART_Popup, Path=Background}"
137-
Height="{x:Static wpf:ComboBoxPopup.ContentPresenterExtend}"/>
139+
Height="{StaticResource PopupContentPresenterExtend}"/>
138140

139141
<ContentPresenter Grid.Row="3"/>
140142

141143
<Border Grid.Row="4"
142144
CornerRadius="0 0 2 2"
143-
Height="{x:Static wpf:ComboBoxPopup.TopBottomMargin}"
145+
Height="{StaticResource PopupTopBottomMargin}"
144146
Background="{Binding ElementName=PART_Popup, Path=Background}" />
145147
</Grid>
146148
</Grid>
147149
</ControlTemplate>
148150

149151
<ControlTemplate x:Key="PopupContentDefaultTemplate" TargetType="ContentControl">
150-
<Grid MinWidth="{Binding ElementName=templateRoot, Path=ActualWidth, Converter={StaticResource MathAddConverter}, ConverterParameter={x:Static wpf:ComboBoxPopup.LeftRightMargin}}"
152+
<Grid MinWidth="{Binding ElementName=templateRoot, Path=ActualWidth, Converter={StaticResource MathAddConverter}, ConverterParameter=32}"
151153
Margin="6">
152154
<Grid.RowDefinitions>
153155
<RowDefinition Height="*" />
@@ -169,13 +171,13 @@
169171
<Border Grid.Row="0"
170172
CornerRadius="2 2 0 0"
171173
Background="{Binding ElementName=PART_Popup, Path=Background}"
172-
Height="{x:Static wpf:ComboBoxPopup.TopBottomMargin}"/>
174+
Height="{StaticResource PopupTopBottomMargin}"/>
173175

174176
<ContentPresenter Grid.Row="1"/>
175177

176178
<Border Grid.Row="2"
177179
CornerRadius="0 0 2 2"
178-
Height="{x:Static wpf:ComboBoxPopup.TopBottomMargin}"
180+
Height="{StaticResource PopupTopBottomMargin}"
179181
Background="{Binding ElementName=PART_Popup, Path=Background}" />
180182
</Grid>
181183
</Grid>

0 commit comments

Comments
 (0)