您好,登錄后才能下訂單哦!
ListView 控件是 Windows Forms 中的一個常用控件,用于顯示和操作數據列表
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
Title="MainWindow" Height="350" Width="525">
<Grid>
<wf:WindowsFormsHost Name="windowsFormsHost"/>
</Grid>
</Window>
using System.Windows;
using System.Windows.Forms;
namespace WpfApp
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ListView listView = new ListView();
listView.View = View.Details;
listView.Columns.Add("Column 1", 100);
listView.Columns.Add("Column 2", 100);
windowsFormsHost.Child = listView;
}
}
}
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid Name="dataGrid"/>
</Grid>
</Window>
using System.Collections.Generic;
using System.Windows;
namespace WpfApp
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<Item> items = new List<Item>
{
new Item { Column1 = "Item 1", Column2 = "Value 1" },
new Item { Column1 = "Item 2", Column2 = "Value 2" },
};
dataGrid.ItemsSource = items;
}
}
public class Item
{
public string Column1 { get; set; }
public string Column2 { get; set; }
}
}
這些方法可以幫助你在 WPF 應用程序中集成 ListView 控件或使用替代方案。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。