Bala
Bala

Reputation: 1476

DataGrid in WPF

Datagrid control is missing in Toolbox. I tried to add it from WPF components, but it is not listing there also. And iam using 3.5 framework

Upvotes: 3

Views: 9255

Answers (2)

Rox
Rox

Reputation: 2023

Instead of a Datagrid, I have used a ListView which contained a GridView. Here is the tutorial I started from. (Haven't worked very much with Datagrid, so I don't know if there are any big differences)

A simplified version of what I'm workign with is:

<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>

Upvotes: 3

slugster
slugster

Reputation: 49984

You can grab it from the WPF Tookit.

Upvotes: 5

Related Questions