Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
数据模板内的WPF弹出窗口_Wpf_Xaml - Fatal编程技术网

数据模板内的WPF弹出窗口

数据模板内的WPF弹出窗口,wpf,xaml,Wpf,Xaml,我需要一个数据模板内的WPF弹出窗口,如下所示: <ScrollViewer> <ItemsControl ItemsSource="{Binding Collection}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <TextBox Name="My

我需要一个数据模板内的WPF弹出窗口,如下所示:

<ScrollViewer>
    <ItemsControl ItemsSource="{Binding Collection}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <TextBox Name="MyTextboxBrief" Text="{Binding TextBrief}"/>
                    <Popup PlacementTarget="{Binding ElementName=MyTextboxBrief}" Placement="Center">
                        <TextBox Name="MyTextboxVerbose" Text="{Binding TextVerbose}"/>
                    </Popup>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>

但是,此弹出窗口的行为应如下所示:

<ScrollViewer>
    <ItemsControl ItemsSource="{Binding Collection}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <TextBox Name="MyTextboxBrief" Text="{Binding TextBrief}"/>
                    <Popup PlacementTarget="{Binding ElementName=MyTextboxBrief}" Placement="Center">
                        <TextBox Name="MyTextboxVerbose" Text="{Binding TextVerbose}"/>
                    </Popup>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>
  • 它必须与相关项控件项一起滚动
  • 当应用程序窗口最小化时,它不应该在桌面上保持可见
  • 它将比ItemsControl高,其内容不得剪裁,但不得更改ItemsControl高度
  • 它将比相关的ItemsControl项宽-但不应将其他ItemsControl项向左或向右移动

  • 我有一种强烈的感觉,我应该以某种方式使用组合框模板-但我不知道如何获得它的弹出行为

    我认为
    Popup
    在这里对您没有帮助,也不
    ComboBox
    。看看这是否对您有进一步的帮助:

    <DataTemplate>
        <Grid>
            <TextBox Name="MyTextboxBrief" Text="{Binding TextBrief}" />
    
    
            <!-- You might want to bind visibility against
                some kind of property -->
            <Canvas >
                <Canvas.RenderTransform>
                     <!--In case you want to move--> 
                    <TranslateTransform Y="-5" />
                </Canvas.RenderTransform>
    
                <Border Width="100" Height="20" Background="Black">
                    <TextBlock Text="Test" />
                </Border>
            </Canvas>
        </Grid>
    </DataTemplate>