文本框不可见,弹出窗口的位置与其下方的标签重叠

时间:2014-08-25 17:37:49

标签: wpf xaml

在我的WPF应用程序中,最初我有一个文本框。

<Window x:Class="Tester.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Test" Height="600" Width="800" >
<StackPanel Margin="10" >
    <Label Content="_Dial String:" Target="{Binding ElementName=txtDialString}" />
    <TextBox Name="txtDialString" />
    <Label Content="_Number of Calls to Generate:" Target="{Binding ElementName=txtCalls}" />
  <DockPanel VerticalAlignment="Center">
        <TextBox Name="txtCalls" Text="{Binding ElementName=sliderCalls,
            Path=Value,UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" Width="22"/>
        <Slider Name="sliderCalls"  TickFrequency="1" TickPlacement="BottomRight"  Minimum="0" Maximum="0"
            IsSnapToTickEnabled="True" ToolTip="Number of calls to dial the specified SIP URI" Width="736"/>

相应的图片喜欢 1

文本框可见。出于某种原因,我想实现类似下拉菜单的多个选择。其他人仍然是一样的。

<Window x:Class="IVRLoadTester.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="IVR Load Test" Height="600" Width="800" >
<Window.Resources>
    <Geometry x:Key="ArrowIcon">M454.165,177.507L422.165,212.46 390.165,177.507 454.165,177.507z</Geometry>
</Window.Resources>
<StackPanel Margin="10" >

    <Label Content="_Dial String:" Target="{Binding ElementName=txtDialString}" />

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"  />
            <ColumnDefinition Width="30" />
        </Grid.ColumnDefinitions>
        <DockPanel Height="30" HorizontalAlignment="Stretch">
            <TextBlock Text="{Binding SelectedString}" x:Name="cboText" HorizontalAlignment="Stretch"
                   VerticalAlignment="Center" />
        </DockPanel>
        <ToggleButton  Grid.Column="1" Width="30" Background="LightGray"
                       x:Name="ToggleDrop"    >

            <Path Data="{StaticResource ArrowIcon}"
                   Stretch="Uniform" Fill="Black" Width="10" Height="10" RenderTransformOrigin="0.5,0.5">
            </Path>

        </ToggleButton>
        <Popup IsOpen="{Binding IsChecked, ElementName=ToggleDrop}"
               PlacementTarget="{Binding ElementName=dp}"
               Placement="Bottom"
               Width="500"
               >
            <ListBox Grid.Row="1"
            ItemsSource="{Binding Items}" 
                 SelectionMode="Extended"  
                 HorizontalContentAlignment="Stretch" 
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 SelectedItem="{Binding SelectedItem}"
                 >
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                        <Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
                        <Setter Property="IsSelected" Value="{Binding IsSelected}"/>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Popup>
    </Grid>
    <Label Content="_Number of Calls to Generate:" Target="{Binding ElementName=txtCalls}" />

    <DockPanel VerticalAlignment="Center">

        <TextBox Name="txtCalls" Text="{Binding ElementName=sliderCalls,
            Path=Value,UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="Right" Width="22"/>

        <Slider Name="sliderCalls"  TickFrequency="1" TickPlacement="BottomRight"  Minimum="0" Maximum="0"
            IsSnapToTickEnabled="True" ToolTip="Number of calls to dial the specified SIP URI" Width="736"/>

图像变为: 2 您看到文本框不可见。为什么? 此外,如果我按下按钮,我会得到图表 3

您会看到弹出窗口覆盖标签,这是不期望的。

请帮助解决这两个问题。

1 个答案:

答案 0 :(得分:0)

首先,弹出封面标签,因为它没有可显示的空间。 Dial String下的Textblock实际上放在那里但没有显示任何内容,显然SelectedString等于null。