2014-10-09 38 views
0

我正在更新數據透視查看器應用程序並遇到以下問題。希望有人會因爲我被卡住而得到答案。如果太多的pivotviewer屬性,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); 
      } 
+0

你可以添加你的代碼的問題? – matsjoyce 2014-10-09 16:48:04

+0

已添加。讓我知道你是否需要額外的代碼部分。 – Trinak 2014-10-09 17:48:29

回答

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

不進行分配在上面的初始屬性?

+0

我不確定我明白你的意思。顯示的初始化器只是加載項目模板。我不認爲這與房產有關。該模板如下所示: Trinak 2014-10-14 16:41:43