I have this ComboBox using the MaterialDesignFilledComboBox style.
<ComboBox ItemsSource="{Binding SomeData}"
Style="{StaticResource MaterialDesignFilledComboBox}"
materialDesign:HintAssist.Hint="Some hint text"
</ComboBox>
Notice the assignment of the materialDesign:HintAssist.Hint="Some hint text" property.
When I have not chosen an item in the ComboBox's drop-down-menu, the Hint property ("Some hint text") is the only visible text in the ComboBox. That is fine.
Above the Hint, there is an "unused space".
If I select an item in the drop-down-menu, the "unused space" is occupied by the Hint and showing the "Some hint text".
Question
My designer dislike the "above space" when there is no item selected in the drop-down-menu.
Is it possible to center the Hint vertically in the ComboBox when there is no item selected?
My findings
Looking into the MaterialDesignFilledComboBox's template (MaterialDesignFloatingHintComboBoxTemplate).
I found the SmartHint control at rows 374 - 397. This control seem to be the placeholder for the Hint.
If I add this style as a resource to the ComboBox, I have some limitied control of the SmartHint object in my ComboBox.
For instance:
<ComboBox ItemsSource="{Binding SomeData}"
Style="{StaticResource MaterialDesignFilledComboBox}"
materialDesign:HintAssist.Hint="Some hint text"
<ComboBox.Resources>
<Style TargetType="materialDesign:SmartHint">
<Setter Property="VirtualizingPanel.Visibility" Value="Collapsed" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<ComboBox.Resources>
</ComboBox>
The setter with the Visibility = Collapsed actually works.
The setters of the VerticalAlignment and the VerticalContentAlignment properties don't work. Even if they would work, they would not given me the exact result I want, but prove that I can control the position of the control in some way.
Any suggestions?
/BR
Steffe
CodePudding user response:
Try changing the Padding property
<Setter Property="Padding" Value="0 -10 0 0" />
CodePudding user response:
Try to set the HintAssist.IsFloating attached property of the ComboBox to false:
<ComboBox ItemsSource="{Binding SomeData}"
Style="{StaticResource MaterialDesignFilledComboBox}"
materialDesign:HintAssist.IsFloating="False"
materialDesign:HintAssist.Hint="Some hint text" />
