首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >PivotViewer如果透视器属性太多,则不显示图像

PivotViewer如果透视器属性太多,则不显示图像
EN

Stack Overflow用户
提问于 2014-10-10 00:44:08
回答 1查看 115关注 0票数 0

我正在更新pivot查看器应用程序,遇到了以下问题。希望有人能在我被卡住的时候给出答案。

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

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

有什么想法吗?

带有一些名称更改的代码(选项二一是具有我注释掉的属性的那个选项):

MainPage.xaml.cs

代码语言:javascript
运行
复制
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:

代码语言:javascript
运行
复制
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中设置了断点,那么继续图像也可以正常加载。

代码语言:javascript
运行
复制
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);
            } 
EN

回答 1

Stack Overflow用户

发布于 2014-10-13 12:33:52

代码语言:javascript
运行
复制
       TemplateCollection = new PivotViewerItemTemplateCollection()
             {
             (PivotViewerItemTemplate)  Application.Current.Resources[SmallTemplate]
             };

没有在上面的初始值设定项中分配属性?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26283740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档