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; }
        }
    

      

  • 相关阅读:
    软件工程实践总结
    beta答辩总结
    beta冲刺(6/7)
    beta 冲刺(5/7)
    beta冲刺(4/7)
    beta冲刺(3/7)
    beta冲刺(2/7)
    beta冲刺(1/7)
    CentOS7安装新版git
    NameError: name 'reload' is not defined
  • 原文地址:https://www.cnblogs.com/zbfamily/p/9370384.html
Copyright © 2011-2022 走看看