zoukankan      html  css  js  c++  java
  • SilverLight:基础控件使用(2)-ComboBox,ListBox控件

    ylbtech-SilverLight-Basic-Control:基础控件使用(2)-ComboBox,ListBox控件

     直接在 XAML 代码中设置 Items 和通过后台代码绑定数据源

    ComboBox,ListBox

    1.A,返回顶部ComboBox(下拉列表框)
    1,
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="46,45,0,0"
              Name="comboBox1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding}">
        <ComboBoxItem Content="北京" />
        <ComboBoxItem Content="上海" IsSelected="True" />
        <ComboBoxItem Content="济南" />
    </ComboBox>
    <dataInput:Label Height="18" HorizontalAlignment="Left" Margin="46,82,0,0"
                        Name="label1" VerticalAlignment="Top" Width="100" />
    <ComboBox Height="23" HorizontalAlignment="Left" Margin="48,111,0,0"
                Name="comboBox2" VerticalAlignment="Top" Width="120" />

    2, Name,Height,Width,

    Content,IsSelected[设为默认选项]

    3,
    //取值
    ComboBoxItem cbi = (ComboBoxItem)comboBox1.SelectedItem;
    label1.Content = cbi.Content;
    
    #region 城市数据源
    IList<ComboBoxItem> cbis = new List<ComboBoxItem>();
    cbis.Add(new ComboBoxItem() { Content="shanghai" });
    cbis.Add(new ComboBoxItem() { Content = "beijing" });
    cbis.Add(new ComboBoxItem() { Content = "ji'nan", IsSelected=true});
    #endregion
    //数据绑定
    comboBox2.ItemsSource = cbis;

    4,

    1.B,返回顶部 ListBox(列表框)
    1,
    <ListBox Height="76" HorizontalAlignment="Left" Margin="64,12,0,0"
                Name="listBox1" VerticalAlignment="Top" Width="120">
        <ListBoxItem Content="上海" />
        <ListBoxItem Content="北京" IsSelected="True" />
        <ListBoxItem Content="济南" />
    </ListBox>
    <dataInput:Label Height="18" HorizontalAlignment="Left" Margin="72,94,0,0"
                Name="label1" VerticalAlignment="Top" Width="100" />
    <ListBox Height="74" HorizontalAlignment="Left" Margin="64,118,0,0"
                Name="listBox2" VerticalAlignment="Top" Width="120" />

    2,Name,Height,Width,

    Content,IsSelected[设为默认选项]

    3,
    //取值
    ListBoxItem lbi = (ListBoxItem)listBox1.SelectedItem;
    label1.Content = lbi.Content;
    
    #region 城市数据源
    IList<ListBoxItem> lbis = new List<ListBoxItem>();
    lbis.Add(new ListBoxItem() { Content = "shanghai" });
    lbis.Add(new ListBoxItem() { Content = "beijing" });
    lbis.Add(new ListBoxItem() { Content = "ji'nan", IsSelected = true });
    #endregion
    //数据绑定
    listBox2.ItemsSource = lbis;

    4,

    1.C,返回顶部
     
    warn 作者:ylbtech
    出处:http://ylbtech.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    关于使用AJAX获取数据时,由于IE缓存而导致数据不更新,串数据的问题!
    优化PHP代码的40条建议(转)
    这么晚了!难得今天看了几个小时的JAVA
    WEB开发,路漫漫其修远兮,个人的求索思考
    (转)高效的MySQL分页
    20121108随笔,关于代码严谨性、编写的优雅性
    Ubuntu 12.04LTS 安装PHP扩展pdo_oci.so支持ORACLE数据库
    程序员应该具备的11项基本技能
    Windows下配置使用MemCached
    PHP浮点数比较
  • 原文地址:https://www.cnblogs.com/ylbtech/p/3397062.html
Copyright © 2011-2022 走看看