2013-01-22 18 views
0

在下面的XAML中,組合框不可見。我究竟做錯了什麼?如果放置多個面板,Combobox不可見

<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

您將第二個網格(包含2個文本塊的網格)放置在帶有組合框的堆棧面板的前面(表示更高的Z順序)。你想實現什麼?請具體說明,我們可以給你一個更好的解決方案 –

回答

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>