WPF中怎么才能实现combobox显示多行而不是单行,help
1个回答
2016-09-22 · 知道合伙人软件行家
关注
展开全部
你试试,看看有没有效果
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Binding
{
/// <summary>
/// Window2.xaml 的交互逻辑
/// </summary>
public partial class Window2 : Window
{
public class ST
{
public int Id { get; set; }
public string Name { get; set; }
public string Grade { get; set; }
}
List<ST> ListSource = new List<ST>()
{
new ST(){ Id =101,Name="S1",Grade="G2"},
new ST(){ Id =102,Name="S2",Grade="G1"},
new ST(){ Id =103,Name="S3",Grade="G4"},
new ST(){ Id =104,Name="S4",Grade="G3"},
};
public Window2()
{
InitializeComponent();
List<ST> list = new List<ST>();
this.dataGrid1.ItemsSource = list;
this.h1.ItemsSource = ListSource;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Binding
{
/// <summary>
/// Window2.xaml 的交互逻辑
/// </summary>
public partial class Window2 : Window
{
public class ST
{
public int Id { get; set; }
public string Name { get; set; }
public string Grade { get; set; }
}
List<ST> ListSource = new List<ST>()
{
new ST(){ Id =101,Name="S1",Grade="G2"},
new ST(){ Id =102,Name="S2",Grade="G1"},
new ST(){ Id =103,Name="S3",Grade="G4"},
new ST(){ Id =104,Name="S4",Grade="G3"},
};
public Window2()
{
InitializeComponent();
List<ST> list = new List<ST>();
this.dataGrid1.ItemsSource = list;
this.h1.ItemsSource = ListSource;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询