DataGrid in WPF

There is no Datagrid control in the toolbar. I tried adding it from WPF components, but it also does not list it. And I use 3.5 framework

+3
source share
2 answers

Instead of Datagrid, I used a ListView that contained a GridView. Here is the tutorial I started with. (Not much worked with Datagrid, so I don’t know if there are big differences)

A simplified version of what I'm working with:

<ListView  ItemsSource="{Binding}" x:Name="lstItems" 
         PreviewMouseLeftButtonDown="lstActions_PreviewMouseLeftButtonDown" 
           PreviewMouseLeftButtonUp="lstActions_PreviewMouseLeftButtonUp">
    <ListView.ItemContainerStyle>
          <Style TargetType="ListViewItem">
              <Setter Property="Height" Value="30" />
          </Style>
    </ListView.ItemContainerStyle>

    <ListView.View>
         <GridView x:Name="gridView">
             <GridViewColumn Width="140" Header="Name" DisplayMemberBinding="{Binding DisplayName}" />
             <GridViewColumn Width="240" Header="Description"  DisplayMemberBinding="{Binding Description}" />
         </GridView>
    </ListView.View>
</Listview>
+3
source

You can grab it from WPF Tookit .

+5
source

Source: https://habr.com/ru/post/1771701/


All Articles