在ComboBox中排列文本

时间:2012-04-04 12:56:34

标签: wpf silverlight xaml combobox

我尝试创建一些正确的XAML 来排列ComboBox右侧的文字,但我不能。

这是我的XAMl ...... 有什么线索我错过了什么? 谢谢!

 <ComboBox Height="25"
           HorizontalAlignment="Left" 
           ItemsSource="{Binding NonArchivedSequences}"  
           SelectedItem="{Binding SelectedSequence}"
           Margin="0,0,0,4" 
           Name="cbSequences" 
           VerticalAlignment="Top" 
           Width="504"                   
           HorizontalContentAlignment="Stretch" 
           SelectionChanged="cbSequences_SelectionChanged"
           Grid.Column="1">
            <ComboBox.Resources>
                <DataTemplate x:Key="DataTemplateSequenceData">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Margin="4,2,2,4"
                                   TextWrapping="Wrap"
                                   Text="{Binding Interval}" 
                                   d:LayoutOverrides="Width, Height"
                                   VerticalAlignment="Center" 
                                   HorizontalAlignment="Left" />
                        <TextBlock Margin="4,2,2,4"
                                   TextWrapping="Wrap"
                                   Text="{Binding Name}" 
                                   d:LayoutOverrides="Width, Height" Grid.Column="1"
                                   VerticalAlignment="Center"
                                   HorizontalAlignment="Left" />
                    </Grid>
                </DataTemplate>
            </ComboBox.Resources>
            <ComboBox.ItemTemplate>
                <StaticResource ResourceKey="DataTemplateSequenceData"/>
            </ComboBox.ItemTemplate>
        </ComboBox>

enter image description here

1 个答案:

答案 0 :(得分:1)

也许Horizo​​ntalAlignment =“正确”你有左