我已经动态地将图像从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
程序集中System.Windows.Controls.Orientation
枚举的值。你的代码应该看起来像:
using System.Windows.Controls;
定向分配:
panoramaItem.Orientation = Orientation.Horizontal;