728x90
반응형
【 WPF & C# (C Sharp) 】 - ListView 예제
@ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp1" xmlns:Properties="clr-namespace:WpfApp1.Properties" x:Class="WpfApp1.MainWindow" mc:Ignorable="d" Title="MainWindow" Height="246.06" Width="347.879"> <Grid Margin="10"> <ListView x:Name="ListView01" HorizontalAlignment="Left" Width="310" Height="139" VerticalAlignment="Top"> <ListView.View> <GridView> <GridViewColumn Header="Name" Width="200" DisplayMemberBinding="{Binding Name}" /> <GridViewColumn Header="Age" Width="100" DisplayMemberBinding="{Binding Age}" /> </GridView> </ListView.View> </ListView> <Button x:Name="btnADD" Content="Button" HorizontalAlignment="Left" Margin="228,144,0,0" VerticalAlignment="Top" Width="82" Height="35" Click="btnADD_Click"/> </Grid> </Window> | cs |
@ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; 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.Navigation; using System.Windows.Shapes; namespace WpfApp1 { /// <summary> /// MainWindow.xaml에 대한 상호 작용 논리 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btnADD_Click(object sender, RoutedEventArgs e) { List<Man> items = new List<Man>(); items.Add(new Man() { Name = "aaa", Age = 23 }); items.Add(new Man() { Name = "bbb", Age = 30 }); ListView01.ItemsSource = items; } } public class Man { public string Name { get; set; } public int Age { get; set; } } } | cs |
@ Memo
내용입력
http://insurang.tistory.com
728x90
반응형
'Programing (프로그래밍) > WPF & C# (C Sharp)' 카테고리의 다른 글
WPF & C# - ini 파일 내 방식대로 읽기 ( ini / cfg / config / txt / sector / 섹터 ) (0) | 2017.10.30 |
---|---|
[ WPF & C# (C Sharp)] - Lib.cs Lib.dll 만들기 (0) | 2017.10.27 |
[ WPF & C# (C Sharp)] - Split / 문자열 자르기 (0) | 2017.10.27 |
[ WPF & C# (C Sharp)] - 두 txt 파일 한줄씩 읽어서 중복 값 제거 (0) | 2017.10.26 |
WPF & C# - 상대경로 구하기 / path ( MakeRelativeUri / Uri ) (0) | 2017.10.25 |
[ WPF & C# (C Sharp)] - 에러 메세지 발생 try ~ catch (0) | 2017.10.24 |
[ WPF & C# (C Sharp)] - 관리자 권한 획득 여부 확인 (0) | 2017.10.24 |
[ WPF & C# (C Sharp)] - 새 창 띄우기 및 전역변수 활용 (0) | 2017.10.24 |