2013-03-22 29 views
0

我正在開發一個應用程序的Windows手機,我最近的問題與列表框。這在我的模擬器上正常工作,但是當我在我的設備上部署時,它不顯示任何內容,但是顯示空白。列表項是根據請求創建的,但綁定不會執行,因爲每個項目單擊時不帶有信息。 與之相關的代碼如下列表框不會出現在設備上

XAML

<ListBox Name="NotesListBox" Grid.Row="0" Margin="15,0" > 
      <ListBox.ItemsPanel> 
       <ItemsPanelTemplate> 
        <toolkit:WrapPanel Orientation="Horizontal" /> 
       </ItemsPanelTemplate> 
      </ListBox.ItemsPanel>     
      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <StackPanel Orientation="Vertical"> 
         <local:NotesTile Name="TileNotes" Tap="NotesTile_Tap_1" Margin="10,10"/> 
         <TextBlock Text="{Binding FileName}" /> 
        </StackPanel> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 

C#代碼背後

List<Notes> source = new List<Notes>() 
      { 
       new Notes(){ Content="This is some text", FileName="one.txt", IsPasswordProtected=true}, 
       new Notes(){ Content="Another text file", FileName="two.txt", IsPasswordProtected=false} 
      }; 


      //this.DataContext = this; 
      this.NotesListBox.ItemsSource = source; 

在同一個命名空間我得到了類如:

class Notes 
{ 
    public string Content { get; set; } 
    public string DateEdited { get; set; } 
    public string TimeEdited { get; set; } 
    public string FileName { get; set; } 
    public bool IsPasswordProtected { get; set; } 
} 

我得到的東西在模擬器上工作得很好,甚至在windows phone 8上也能正常工作。我的應用程序被拒絕了市場出於同樣的原因。

編輯

Binding類應該始終是公開的。將課堂筆記公開可以解決這個問題。

+0

嘿亞!我剛剛找到答案,以修改該類爲公共,它運作良好......任何人都可以告訴我一些原因背後? – Mani 2013-03-26 17:18:21

回答

0

嘗試在InitilizeComponent()之前在xaml.cs的構造函數中設置this.DataContext = this;並讓我們知道它的工作。

+0

這並沒有解決我的問題...該應用程序仍然不顯示任何瓷磚內容。那麼這在Windows Phone 8上正常工作,就像我提交給開發中心時所說的那樣。所以我的模擬器是8,所以我認爲這就是它在我的模擬器上正常工作的原因。 7中有什麼問題? – Mani 2013-03-26 15:41:46

相關問題