xaml – Silverlight中的Stretch ComboBox内容

这让我疯了.我似乎无法在我的ComboBox中获取数据模板来拉伸下拉的宽度.是什么赋予了?

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="30" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <ComboBox x:Name="SearchesComboBox" HorizontalContentAlignment="Stretch" Width="150">
        <ComboBox.ItemContainerStyle>
            <Style TargetType="ComboBoxItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ComboBox.ItemContainerStyle>
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <Border BorderBrush="Black" BorderThickness="1">
                    <TextBlock Text="{Binding}" Margin="2" />
                </Border>
            </DataTemplate>
        </ComboBox.ItemTemplate>
        <sys:String>Two</sys:String>
        <sys:String>Four</sys:String>
        <sys:String>Six</sys:String>
    </ComboBox>
</Grid>
<ComboBox.ItemContainerStyle>
    <Style TargetType="ComboBoxItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    </Style>
</ComboBox.ItemContainerStyle>
相关文章
相关标签/搜索