bradgonesurfing
bradgonesurfing

Reputation: 32162

An alternative to WPF DataGrid that exposes controls as if they were placed on a Grid control

I'm using the WPF DataGrid and it is terrible. It assumes I want a user interface experience based on rows or cell selection, that first I must select a cell/row then click again to put it into edit mode.

I'm aware that there are a number of solutions that suggest a number of hacks to do single click editing with the DataGrid. However getting this working perfectly assuming that I might put any type of control into a column just doesn't work reliably.

What I'm looking for is a grid control that drops child controls into columns as if they were put there manually. So it is more like an ItemsControl generated grid layout rather than an all bells and whistles DataGrid.

Using SharedColumns feature of the Grid layout will not work either as other developers have noticed. At some point of complexity SharedColumns goes unstable and the layout starts jumping and flickering and locks up.

Any suggestions?

Upvotes: 3

Views: 7671

Answers (1)

BradleyDotNET
BradleyDotNET

Reputation: 61349

You could do this by binding to a different control, like a list box and using the Item Template to generate your "columns" (probably by using fixed width items in a horizontal stack panel), ie.

<ListBox ItemsSource="{Binding Path=MyData}">
   <ListBox.ItemTemplate>
      <StackPanel Orientation="Horizontal">
         ...Bunch of text boxes, etc....
      </StackPanel>
   </ListBox.ItemTemplate>
</ListBox>

You can also use a ListView, which supports item templates and comes with a pre-made GridView "style": http://msdn.microsoft.com/en-us/library/system.windows.controls.listview.aspx

Upvotes: 3

Related Questions