如果pivotviewer属性太多,PivotViewer不会显示图像

时间:2014-10-09 16:44:08

标签: pivotviewer

我正在更新数据透视表查看器应用程序并遇到以下问题。希望有人会因为我被困住而得到答案。

问题:当页面加载时,具有属性和其他功能的一面加载正常,但交易卡不加载任何图像。其中一些加载默认的白色背景,而大多数显示深灰色,几乎是黑色背景。所有这些都可以放大并显示所有属性,但没有图像。

调试:我发现注释掉一些属性会导致图像每次都正确加载。如果我只注释1或2,那么图像将加载一些时间(大约10个页面刷新中的2个)。目前,列表中包含29个属性,数据从数据库加载,然后在pivotviewer.ItemsSource中使用。

有什么想法吗?

代码有一些名称更改(选项二是具有我正在评论的属性的那个):

MainPage.xaml.cs中

public MainPage()
    {
       InitializeComponent();

       PivotViewModel pivotModel = new PivotViewModel();
       CollectionsComboBox.SelectedIndex = 0;
       this.DataContext = pivotModel;
    }

    private void DropDown_ItemSelected(object sender, EventArgs e)
    {
        // Process selected index change here
        if (((ComboBox)sender).SelectedValue == "Option One")
        {
            OptionOnePivotViewModel OptionOnePivot = new OptionOnePivotViewModel();
            PivotViewer.ItemsSource = OptionOnePivot.Data;
            PivotViewer.PivotProperties = OptionOnePivot.PivotProperties;
            PivotViewer.ItemTemplates = OptionOnePivot.TemplateCollection;
            PivotViewer.ItemAdornerStyle = blankAdorner;  
        }
        else
        {
            OptionTwoPivotViewModel OptionTwoPivot = new OptionTwoPivotViewModel();
            PivotViewer.ItemsSource = OptionTwoPivot.Data;
            PivotViewer.PivotProperties = OptionTwoPivot.PivotProperties;
            PivotViewer.ItemAdornerStyle = basicAdorner;
            PivotViewer.ItemTemplates = OptionTwoPivot.TemplateCollection;
        }
    }

OptionTwoPivotViewModel.cs:

public OptionTwoPivotViewModel()
        {
            DomainContext = new OptionTwoDomainContext();
            Data = DomainContext.Load(DomainContext.GetHRDatasQuery()).Entities;
            PivotProperties = getPivotProperties();
            SmallTemplate = "EmpSmall";

            TemplateCollection = new PivotViewerItemTemplateCollection()
                 {
                 (PivotViewerItemTemplate)  Application.Current.Resources[SmallTemplate]
                 };
        }

        private List<PivotViewerProperty> getPivotProperties()
        {
            List<PivotViewerProperty> properties = new List<PivotViewerProperty>
            {
                new PivotViewerStringProperty{ Id="Name", Options=PivotViewerPropertyOptions.CanSearchText, DisplayName="Name", Binding=new System.Windows.Data.Binding("Name")},
                new PivotViewerStringProperty{ Id="Status", Options=PivotViewerPropertyOptions.CanFilter, DisplayName="Status", Binding=new System.Windows.Data.Binding("Status")},
                new PivotViewerDateTimeProperty{ Id="StartDate", Options=PivotViewerPropertyOptions.CanFilter, DisplayName="Start Date", Binding=new System.Windows.Data.Binding("StartDate")},
                //additional properties follow...
         };
            return properties;

编辑:我注意到如果我在以下属性getter中设置断点,那么继续图像也可以正常加载。

public ImageSource BackgroundImage
        {
            get
            {
                string location = Image_Location;
                location = location.Substring(location.LastIndexOf("/"));
                Uri uri;

                if (Image_Location.Contains(".gif"))
                {
                    uri = new Uri(Image_Location, UriKind.Absolute);
                }
                else
                {
                    var host = Application.Current.Host.Source.Host;
                    uri = new Uri("https://" + host + "/fileLibrary/employees/images/500"+location, UriKind.RelativeOrAbsolute);
                }

                // set the image source 
                BitmapImage bmpImg = new BitmapImage(uri);
                _loaded = _backgroundImage != null;
                if (!_loaded)
                {
                    bmpImg.ImageOpened += ImageOpened;
                    bmpImg.ImageFailed += ImageFailed;
                }
                return new BitmapImage(uri);
            } 

1 个答案:

答案 0 :(得分:0)

       TemplateCollection = new PivotViewerItemTemplateCollection()
             {
             (PivotViewerItemTemplate)  Application.Current.Resources[SmallTemplate]
             };

不在上面的初始值设定项中指定属性?