I'm trying to line up a TextBox and a ComboBox inside of a StackPanel, but the ComboBox seems to have some extra space at the top of it that I can't get rid of.
How can I get these two controls to align with each other properly?
<StackPanel Orientation="Horizontal">
<TextBox IsTextPredictionEnabled="False" Margin="0,0,0,0" BorderBrush="Gray"
Text="{Binding ZoneName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PlaceholderText="YourCompany"/>
<ComboBox VerticalAlignment="Stretch" BorderBrush="Gray" Padding="0,0,0,0" Margin="0,0,0,0"
ItemsSource="{Binding Path=DomainChoices}"
SelectedValue="{Binding Path=SelectedDomainChoice, Mode=TwoWay}"
SelectedValuePath="{Binding id}"
DisplayMemberPath="{Binding text}"
Foreground="Black" Width="200">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding text}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
When you take a look at ComboBox's style then you will find that <Border x:Name="ShortListOuterBorder" ....
has a Margin with value of Margin="{ThemeResource PhoneTouchTargetOverhang}"
. This resource is defined in the style above:
<Thickness x:Key="PhoneTouchTargetOverhang">0,9.5</Thickness>
You can easily define your own style in which you can change the above value, or change margin of the Border. You can also try to set the margin of your ComboBox to 0,-9.5,0,0
without applying the style.