我想從xaml綁定列表框,但似乎我做錯了它。這是我的XAML頁面。ListBox ItemsSource不適用於XAML
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<phone:Pivot Title="MY APPLICATION">
<!--Pivot item two-->
<phone:PivotItem Header="item2">
<Grid>
<ListBox Foreground="Black" x:Name="ls" ItemsSource="{Binding MyLang}" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Language}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</phone:PivotItem>
</phone:Pivot>
</Grid>
背後
DataSource ds = null;
public List<TranslationLanguage> MyLang;
public PivotPage2()
{
ds = new DataSource();
MyLang = ds.getTranslationLanguages(); //return collections and contains 13 rows
InitializeComponent();
DataContext = this;
}
public class TranslationLanguage
{
[PrimaryKey]
public byte LanguageID{get;set;}
public string Language{get;set;}
public string Description { get; set; }
public bool IsActive { get; set; }
public FlowDirection FlowDirection { get; set; }
public string DownloadURL { get; set; }
public bool IsDownloaded { get; set; }
public string ImagePath { get; set; }
}
我真的很困惑,爲什麼它不能在所有的工作代碼?
謝謝!這工作! – ARH