1

我有一个工作中的pivotviewer,里面有我自己拼凑的128张汽车图像。我使用了网络上的众多教程之一来使其正常工作,并且效果很好。然后我想我应该稍微装饰一下页面,所以我把 pv 所在的网格放在一个边界堆栈面板中,上面有几个文本块来告诉集合是什么。除图像外,一切都加载正常。注释掉堆栈面板行,它可以完美运行。

有任何想法吗?这么简单的事情怎么会失败?

这是 MainPage.xaml 中的所有代码:

<StackPanel>
    <TextBlock
        FontSize="24"
        HorizontalAlignment="Center"
        VerticalAlignment="Top">
        Silverlight Pivotviewer Example
    </TextBlock>
    <TextBlock
        FontSize="16"
        HorizontalAlignment="Center"
        VerticalAlignment="top">
        Cool Automobiles
    </TextBlock>
    <Grid x:Name="LayoutRoot" Background="White">
        <pivoter:PivotViewer x:Name="pivotViewer" />
    </Grid>
</StackPanel>

4

3 回答 3

0

这是一个已知的问题。StackPanel 是一个无量纲元素。您需要将 Width 和 Height 值添加到 StackPanel,PivotViewer 将开始正常工作。

于 2011-04-26T14:48:23.300 回答
0

这就是我们所做的。我们向对话框上的 SizeChanged 事件添加了一个事件处理程序,然后调整 PivotViewer 的大小。在 Initialise 或 Loaded 事件之后也调用它......看看你怎么样?

  void PivotDialog_SizeChanged( object sender, SizeChangedEventArgs e )
  {
     SizePivotViewer( );
     m_PivotViewer.UpdateLayout( );
  }

  private void SizePivotViewer( )
  {
     m_PivotViewer.Width = ActualWidth;
     m_PivotViewer.Height = ActualHeight - 20; // Magic number so text will display properly at bottom of Pivot!
  }
于 2011-11-15T03:13:57.087 回答
0

您的网格“LayoutRoot”是您的主要布局控件。您需要将 StackPanel 包装在 Grid 控件中。

像这样的东西:

<Grid x:Name="LayoutRoot" Background="White"
  <StackPanel>
    <TextBlock
        FontSize="24"
        HorizontalAlignment="Center"
        VerticalAlignment="Top">
        Silverlight Pivotviewer Example />
    <TextBlock
        FontSize="16"
        HorizontalAlignment="Center"
        VerticalAlignment="top">
        Cool Automobiles />
    <pivoter:PivotViewer x:Name="pivotViewer" />
  </StackPanel>
</Grid>

在你声明你的网格之后,我会添加一些行,即 0、1、2。然后我会布局你的 Stackpanels、Pivo​​tViewer 等。

希望这可以帮助。

于 2011-03-30T20:38:16.057 回答