日期:2014-05-17  浏览次数:20969 次

WPF中控件显示问题,Z轴显示不对,控件被遮住了
我在GroupBox控件中有一个ListBox
我想让ListBox显示在GroupBox之上,怎么设置都不对,能不能显示啊
XML code

<GroupBox Header="运输信息" Panel.ZIndex="5">
                                
                                <StackPanel Orientation="Horizontal">
                                    <Label Content="代单号:"></Label>
                                    <TextBox Name="txtOrderid" Width="130" Height="20"></TextBox>
                                    <Label Content="起点:" Margin="30,0,0,0"></Label>
                                    <Canvas Width="130" Panel.ZIndex="7">
                                        
                                        <TextBox Name="txtSstie" Width="130" Height="20" PreviewKeyUp="txtSstie_PreviewKeyUp"></TextBox>
                                        <ListBox Name="lstSsite" Width="130" Margin="0,20,0,0" Height="70" Visibility="Collapsed" >
                                            <ListBoxItem Content="sdfafdas" />
                                            <ListBoxItem Content="asdfasdfasdfsa" />
                                            <ListBoxItem Content="asdfadfasd" />
                                        </ListBox>
                                    </Canvas>
                                    <Label Content="终点:"></Label>
                                    <Canvas Width="130">
                                        <TextBox Name="txtEstie" Width="130" Height="20"></TextBox>
                                        <ListBox Name="lstEsite" Width="130" Margin="0,20,0,0" Visibility="Collapsed"></ListBox>
                                    </Canvas>
                                    <Label Content="运输方式:" Margin="30,0,0,0"></Label>
                                    <ComboBox Name="cmbTranWay" Width="90"></ComboBox>
                                </StackPanel>
                            </GroupBox>





------解决方案--------------------
listbox放外层,不要放在GroupBox里面,否则作为GroupBox的子控件,肯定不能跑到GroupBox的上层来。
------解决方案--------------------
Canvas 里面的控件 z 才有效