在下面的XAML中,组合框不可见。我做错了什么?
<Grid>
<StackPanel>
<ComboBox Name="combo1"
ItemsSource="{Binding}"
DisplayMemberPath="PartNumber" />
</StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="{Binding ElementName=combo1, Path=SelectedItem.PartName}"
Background="AliceBlue" />
<TextBlock Grid.Row="0"
Grid.Column="1"
Text="{Binding ElementName=combo1, Path=SelectedItem.PartQuantity}"
Background="Beige" />
</Grid>
</Grid>
答案 0 :(得分:1)
您已将网格放置在导致问题的组合框上方,您可以为组合添加新行,也可以使用画布指定zIndex。请查看下面的xaml部分。
<Canvas>
<ComboBox Canvas.ZIndex="2"
Width="300"
Name="combo1"
ItemsSource="{Binding}"
DisplayMemberPath="PartNumber" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="{Binding ElementName=combo1, Path=SelectedItem.PartName}"
Background="AliceBlue" />
<TextBlock Grid.Row="0"
Grid.Column="1"
Text="{Binding ElementName=combo1, Path=SelectedItem.PartQuantity}"
Background="Beige" />
</Grid>
</Canvas>