【问题标题】:How make Horizontal Orientation of PanoramaItem in Panorama.ItemTemplate?如何在 Panorama.ItemTemplate 中制作 PanoramaItem 的水平方向?
【发布时间】:2012-05-12 13:25:22
【问题描述】:

在我的 Windows Phone 应用程序中,我有:

 <controls:Panorama.ItemTemplate>
                <DataTemplate>
                    <Grid Visibility="{Binding ItemVisibility}" Margin="0,-60,0,0">
                        <ScrollViewer Margin="0,0,0,0"  VerticalAlignment="Top" Height="Auto">
                            <StackPanel Margin="0,0,0,0" Width="Auto"  >
                                <RichTextBox x:Name="Browser"  IsReadOnly="True" Foreground="Black" Height="Auto" cxi:WebBrowserHelper.Html="{Binding BrowserHtml}"  HorizontalAlignment="Left"   Width="460" Margin="0,0,0,0" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" />
                                <Canvas Height="100" Width="0" />
                            </StackPanel>
                        </ScrollViewer>
                    </Grid>
                </DataTemplate>
            </controls:Panorama.ItemTemplate>

如何使 PanoramaItem 的方向 - Orientation = "Horizo​​ntal"?

我试过了:

<controls:Panorama.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
        </controls:Panorama.ItemsPanel>

但是有 NullReference Exeption

【问题讨论】:

    标签: c# silverlight windows-phone-7 silverlight-4.0 silverlight-3.0


    【解决方案1】:

    首先,这听起来有点奇怪。全景控件内部的项目宽度不应很大,也不应在那里进行水平滚动,因为它可能会破坏用户体验(用户将滚动 PanoramaItem 内部的内容还是 Panorama 本身以切换到另一个全景项目)

    不用修改ItemsPanel模板,只需修改PanoramaItem内容中的StackPanel即可。类似的东西:

    <StackPanel Margin="0,0,0,0" Width="Auto" Orientation="Horizontal"  > 
                                        <RichTextBox x:Name="Browser"  IsReadOnly="True" Foreground="Black" Height="Auto" cxi:WebBrowserHelper.Html="{Binding BrowserHtml}"  HorizontalAlignment="Left"   Width="460" Margin="0,0,0,0" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" /> 
                                        <Canvas Height="100" Width="0" />
    </StackPanel>
    

    【讨论】:

    • 这无济于事,因为我仍然在全景图中看到下一个项目
    • 您是否尝试过在 DataTemplate 中使用 PanoramaItem 而不是(或在其之上)Grid? (类似于 Panorama.ItemTemplate -> DataTemplate -> PanoramaItem -> Grid)
    • 谢谢,但没用,项目的宽度变窄了一点
    猜你喜欢
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-22
    • 1970-01-01
    • 2011-10-09
    • 2011-08-05
    • 2012-02-18
    相关资源
    最近更新 更多