-
[WPF] ListViewMicrosoft .NET/WPF 2019. 5. 13. 14:06
Table 형식으로 데이터를 출력함.
<ListView x:Name="listview" VerticalContentAlignment="Center"> <ListView.View> <GridView> <GridViewColumn Header="1" Width="100" > <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding check}" ToolTip="{Binding name}" Width="20" Height="30" Margin="0,15,0,0"> </CheckBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="" Width="240"> <GridViewColumn.CellTemplate> <DataTemplate> <Label Content="{Binding name}" Foreground="Red" FontSize="12"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>
ItemTemplate으로 데이터를 표현하고 다양한 구성으로 배치가 가능.
<ListView Name="lvWorks" Grid.Row="3" Grid.ColumnSpan="10" ItemsSource="{x:Static local:StaticData.ocWorks}"> <ListView.ItemTemplate> <DataTemplate> <Grid Width="730"> <StackPanel Name="stp" Orientation="Horizontal" Width="auto"> <Border Width="730" Padding="1" Background="LightGray"> <Grid Width="730" Margin="1"> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="30"/> <ColumnDefinition Width="170"/> <ColumnDefinition Width="100"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/> <ColumnDefinition Width="70"/> </Grid.ColumnDefinitions> <Border Grid.Column="0" Grid.RowSpan="2" Width="30" BorderThickness="0,0,1,0" BorderBrush="Gray"> <Label Content="{Binding idx}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="15" FontWeight="Bold" Foreground="DimGray" /> </Border> <Border Grid.Column="1" Width="170" BorderThickness="0,0,0,1" BorderBrush="Gray"> <Label Content="{Binding type}" FontSize="15" FontWeight="Bold" /> </Border> <Border Width="100" Grid.Column="2" BorderThickness="1,0,0,1" BorderBrush="Gray"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="40"/> <ColumnDefinition Width="60"/> </Grid.ColumnDefinitions> <Label Content="Loop" Grid.Column="0" Width="40"/> <ComboBox SelectedItem="{Binding loop}" Grid.Column="1" Width="55" ItemsSource="{x:Static local:StaticData.ocLoopCount}"> </ComboBox> </Grid> </Border> <Label Content="{Binding definition}" ToolTip="{Binding data}" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="5"/> <Button Name="btnSetting" Grid.Column="5" Grid.RowSpan="2" Width="60" Content="Setting" Click="BtnSetting_Click"/> </Grid> </Border> </StackPanel> </Grid> </DataTemplate> </ListView.ItemTemplate> </ListView>
'Microsoft .NET > WPF' 카테고리의 다른 글
[WPF] '_' 문자가 출력되지 않는 경우! (Underline, Underscore) (0) 2019.07.03 [WPF] Timer ( DispatcherTimer ) (0) 2019.07.03 [WPF] 1. 화면 구성 - WrapPanel (0) 2019.02.27 [WPF] 1. 화면 구성 - StackPanel (0) 2019.02.27 [WPF] 1. 화면 구성 - Grid (0) 2019.02.25