简体   繁体   English

Windows Phone 8.1中的项目控件弹出问题

[英]Problems with flyout over itemscontrol in Windows Phone 8.1

I've got the following piece of XAML code: 我有以下XAML代码:

    <Grid Grid.Row="1" x:Name="ContentRoot" Margin="19,9.5,19,0">
        <ScrollViewer>
            <ItemsControl ItemsSource="{Binding History}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" Tapped="HistoryItemTapped">
                            <FlyoutBase.AttachedFlyout>
                                <Flyout>
                                    <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                        <ScrollViewer>
                                            <TextBlock Foreground="{ThemeResource PhoneMidBrush}" FontSize="{ThemeResource TextStyleExtraLargeFontSize}" HorizontalAlignment="Left" Text="{Binding Expression}" />
                                        </ScrollViewer>
                                        <ScrollViewer>
                                            <TextBlock FontSize="{ThemeResource TextStyleExtraLargePlusFontSize}" HorizontalAlignment="Right" Text="{Binding Result}" />
                                        </ScrollViewer>
                                    </StackPanel>
                                </Flyout>
                            </FlyoutBase.AttachedFlyout>
                            <TextBlock Foreground="{ThemeResource PhoneMidBrush}" FontSize="{ThemeResource TextStyleExtraLargeFontSize}" HorizontalAlignment="Left" Text="{Binding Expression}" 
                                       TextTrimming="CharacterEllipsis"/>
                            <TextBlock FontSize="{ThemeResource TextStyleExtraLargePlusFontSize}" HorizontalAlignment="Right" Text="{Binding Result}" 
                                       TextTrimming="CharacterEllipsis"/>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>

There are two problems I can't solve: 我无法解决两个问题:

  1. The flyout is shown upon tapping on one of items: 点按以下项目之一即可显示弹出窗口:

     private void HistoryItemTapped(object sender, TappedRoutedEventArgs e) { FlyoutBase.GetAttachedFlyout((FrameworkElement)sender).ShowAt((FrameworkElement)sender); } 

    However, no matter how I set up the flyout it always shows on the top of the screen, not over the tapped item. 但是,无论我如何设置弹出按钮,弹出按钮始终显示在屏幕顶部,而不显示在所点击的项目上方。 Why? 为什么?

  2. The flyout contains two TextBlocks on separate ScrollViewers. 弹出按钮在单独的ScrollViewer上包含两个TextBlocks。 The text on one of them exceeds width of the flyout, bt the scrollviewer does not appear to be working (I cannot scroll horizontally the textblock). 其中之一上的文本超出了弹出窗口的宽度,但滚动查看器似乎无法正常工作(我无法水平滚动文本块)。 Why is that? 这是为什么?

So let's knock these out real quick. 因此,让我们快速地将它们淘汰掉。 Your #1 would be expected result, it's just going off the default FlyoutPlacementMode enumeration wherein generally your flyout is just meant to appear over the top in one of 5 spots, Top, Bottom, Left, Right, or Full(Center) 您的#1会是预期的结果,它只是关闭了默认的FlyoutPlacementMode枚举,通常情况下,弹出按钮只是显示在顶部,底部,左侧,右侧或全(中心)5个位置之一的顶部

How to fix it, ditch the flyout control and just animate your own panel to do the same thing on a tap event or whatever, not hard at all. 如何修复它,抛开弹出控件,只为自己的面板设置动画,以便在轻拍事件或其他事情上做同样的事情,一点也不难。

Your #2, if I remember right the default on ScrollViewer for something like the HorizontalScrollBarVisibility is False by default. #2,如果我还记得正确的ScrollViewer上的默认值,例如HorizontalScrollBarVisibility默认为False。 So just add HorizontalScrollBarVisibility="Auto" to it. 因此,只需向其添加Horizo​​ntalScrollBarVisibility =“ Auto”。

Hope this helps, cheers 希望这会有所帮助,欢呼

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM