zoukankan      html  css  js  c++  java
  • wpf listboxitem添加下划线

    1.通过List<string>进行赋值,没有字段绑定

    // 前台xaml
            <ListBox x:Name="list1">
                <ListBox.ItemTemplate>
                    <DataTemplate DataType="ListBoxItem">
                        <Border BorderBrush="Red" BorderThickness="0,0,0,1">
                            <ContentControl Content="{Binding}"/>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
    // 后台赋值
    private void SetListBoxItemsSource()
            {
                List<string> list = new List<string>();
                for (int i = 0; i < 10; i++)
                {
                    list.Add("listboxitem" + i);
                }
                list1.ItemsSource = list;
            }

    1.可用字段绑定

    // 前台xaml
            <ListBox x:Name="list1">
                <ListBox.ItemTemplate>
                    <DataTemplate DataType="ListBoxItem">
                        <Border BorderBrush="Red" BorderThickness="0,0,0,1">
                            <ContentControl Content="{Binding name}"/>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
    // 后台cs
            private void SetListBoxItemsSource()
            {
                List<Person> list = new List<Person>();
                for (int i = 0; i < 10; i++)
                {
                    list.Add(new Person() { name = "名字" + i, age = "2" + i });
                }
                list1.ItemsSource = list;
            }
    // 类实体
        class Person
        {
            public string name { get; set; }
            public string age { get; set; }
        }
    

      

  • 相关阅读:
    bzoj2045: 双亲数&bzoj1101: [POI2007]Zap
    spoj GCDEX
    jQuery Ajax
    jQuery 动画效果
    jQuery 事件处理API
    jQuery 常用getter&setter
    jQuery 文档操作
    jQuery 基础
    Vue2.2.0+新特性整理
    JavaScript中的HTTP
  • 原文地址:https://www.cnblogs.com/zbfamily/p/9370384.html
Copyright © 2011-2022 走看看