zoukankan      html  css  js  c++  java
  • wp7DataTemplates

    <UserControl x:Class="DataTemplates.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
    <RowDefinition />
    <RowDefinition />
    </Grid.RowDefinitions>

    <Grid.Resources>
    <DataTemplate x:Key="CBTemplate">
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition />
    <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Image Grid.Column="0" Width="50" Height="50"
    Source="{Binding Photo}" Stretch="Fill"/>
    <TextBlock Grid.Column="1" Text="{Binding Title}"
    Margin="10" HorizontalAlignment="Left" FontSize="20"/>
    </Grid>
    </DataTemplate>
    </Grid.Resources>

    <ComboBox x:Name="CB1" VerticalAlignment="Top" HorizontalAlignment="Left"
    ItemTemplate="{StaticResource CBTemplate}" ItemsSource="{Binding}" />


    </Grid>
    </UserControl>

    namespace DataTemplates
    {
    public partial class Page : UserControl
    {
    ObservableCollection<Thing> MyThings;
    public Page()
    {
    InitializeComponent();

    //Create collection
    MyThings = new ObservableCollection<Thing>();

    //Create each object in the collection
    Thing flower = new Thing("Flower", "flower.jpg");
    Thing snake = new Thing("Snake", "snake.jpg");
    Thing sunset = new Thing("Sunset", "sunset.jpg");

    //Add the objects to the collection
    MyThings.Add(flower);
    MyThings.Add(snake);
    MyThings.Add(sunset);

    //LayoutRoot is the name of the root Grid
    LayoutRoot.DataContext = MyThings;
    }


    }

    public class Thing
    {
    public Thing(string title, string imageUri)
    {
    this.Title = title;
    this.Photo = imageUri;
    }

    public string Photo { get; set; }
    public string Title { get; set; }

    }
    }

  • 相关阅读:
    web服务器-Apache
    nginx优化
    nginx下载限速
    nginx-URL重写
    HDU 5358 First One 求和(序列求和,优化)
    HDU 5360 Hiking 登山 (优先队列,排序)
    HDU 5353 Average 糖果分配(模拟,图)
    UVALive 4128 Steam Roller 蒸汽式压路机(最短路,变形) WA中。。。。。
    HDU 5348 MZL's endless loop 给边定向(欧拉回路,最大流)
    HDU 5344 MZL's xor (水题)
  • 原文地址:https://www.cnblogs.com/androllen/p/3107730.html
Copyright © 2011-2022 走看看