Wpf 通过WP7中的代码设置全景项目方向

Wpf 通过WP7中的代码设置全景项目方向,wpf,windows-phone-7,c#-4.0,silverlight-4.0,Wpf,Windows Phone 7,C# 4.0,Silverlight 4.0,我已经将图像动态地从url添加到全景项目。我需要的宽度是800的图像应该在下一个项目的空间也。为此,在我以前的应用程序中,我在Xaml中将方向设置为水平。但不,我需要在代码中设置,但我不能有任何方法可以做到这一点 private void AddItem(string uri, string header) { var panoramaItem = new PanoramaItem(); panoramaItem.Width = 800;

我已经将图像动态地从url添加到全景项目。我需要的宽度是800的图像应该在下一个项目的空间也。为此,在我以前的应用程序中,我在Xaml中将方向设置为水平。但不,我需要在代码中设置,但我不能有任何方法可以做到这一点

private void AddItem(string uri, string header)
    {
        var panoramaItem = new PanoramaItem();
        panoramaItem.Width = 800;
        panoramaItem.Height = 550;

        panoramaItem.Header = "";
        var grid = new Grid();

        var image = new Image();

        image.Source = new BitmapImage(new Uri(uri, UriKind.RelativeOrAbsolute));

        panoramaItem.Content = image;
        pan.Items.Add(panoramaItem);
    }

PanoramaItem
具有用于处理滚动方向的
Orientation
属性。它接受
System.Windows
assembly中
System.Windows.Controls.Orientation
enum的值。您的代码应该如下所示:

using System.Windows.Controls;
和定向协助:

panoramaItem.Orientation = Orientation.Horizontal;

panoramaItem.Orientation=Orientation.Horizontal
不起作用,或者?当我输入panoramaItem.Orientation=Orientation时,然后在智能意义上,我没有看到仅水平和垂直比较的选项,等于,我可以知道是什么原因吗?使用
System.Windows.Controls.Orientation.Horizontal
我只有System.Windows.Controls.common或primitives..添加对
System.Windows
assembly的引用在上面的代码中,我将方向设置为水平。现在,第一个全景项目出现在一段距离内,看起来像第二个项目。当我水平翻转时,第一个项目空间为空。第一个图像看起来像第二个项目。即,第一个图像从我的应用程序的全景控件标题的一半开始。第一个全景项目不是从字母M开始,而是从PPL开始。很难理解你看到了什么。也许,这有助于您:默认的
图像
拉伸
方法是
统一
。因此,如果您的图像不是800x550,您将看到一些空白区域。但是,这是另一个问题。。。