然后我们打开VS2012,选择Windows Metro Style,然后选择创建Blank App项目如下图:
其新建完成的项目结构如下:
我们拖动一个按钮和ListBox到界面中,设置按钮事件以及ListBox的DataTemplate,如下Xaml代码:
复制代码代码如下:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Button" Name="button1" HorizontalAlignment="Left"
Margin="135,124,0,0" VerticalAlignment="Top" Click="button1_Click"/>
<ListBox HorizontalAlignment="Left" Name="listbox1" Height="100"
Margin="135,187,0,0" VerticalAlignment="Top" Width="140">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="60" Text="{Binding ItemName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
其Xaml.cs文件如下:
复制代码代码如下:
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
listbox1.ItemsSource = ItemModel.GetItem();
button1.Content = "Windows 8按钮";
}</p>
<p> /// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}</p>
<p> private void button1_Click(object sender, RoutedEventArgs e)
{
this.button1.Content = this.button1.Content + "1";
}
}
ListBox绑定的数据源代码如下:
复制代码代码如下:
public class ItemModel
{
public string ItemName { get; set; }</p>
<p> public string ItemValue { get; set; }</p>
<p> public static List<ItemModel> GetItem()
{
List<ItemModel> list = new List<ItemModel>();
list.Add(new ItemModel() { ItemName = "北京", ItemValue = "010" });
list.Add(new ItemModel() { ItemName = "上海", ItemValue = "020" });
list.Add(new ItemModel() { ItemName = "成都", ItemValue = "028" });
return list;
}
}
更新动态
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]