locked
Data Grid View in windows store apps RRS feed

  • Question

  • I have made an app in windows form in which I have used buttons and datagridview. After then I wanted o make that app with metro style but there is no DatagridView tool in windows store app toolbox. Can u suggest what to do ?
        There is no any section of windows store app thats why I am posting here .

    Thanks...
    Sunday, January 13, 2013 11:51 PM

Answers

  • There is indeed no DataGrid(View) in WinRT.

    With the present standard widget collection, the closest you can come is using a ListView with fixed [different] column sizes and whose Header mimics the column headers. Styling and templating capabilities for the individual 'rows' are quite powerful. But it remains an 'approximation'.

    Otherwise, you'll have to resort to 3rd party widget providers for WinRT.

    • Proposed as answer by Dave SmitsMVP Monday, January 14, 2013 9:23 AM
    • Marked as answer by Min ZhuMember Thursday, January 24, 2013 7:49 AM
    Monday, January 14, 2013 6:39 AM
  • If you only need a basic table and don't want to mess with 3rd party controls, it's easy enough to create a mock table. For some basic tables in my apps, I used an ItemsControl inside a ScrollViewer. You need to be content with fixed column widths however. The header was also more of an illusion that sat above of the items control. It's far from an elegant solution but it's reasonably simple and looks ok. I haven't tried using controls derived from ItemsControl for making a table so I can't say if they make things easier or harder.

    Here's a rough outline:.

    • Border
      • StackPanel (horizontal)
        • TextBlock (column 1 – fixed width matching first element in data template)
        • TextBlock (column 2 – fixed width matching second element in data template)
        • TextBlock (column 3 – fixed width matching third element in data template)
    • ScrollViewer (with border)
      • ItemsControl
        • StackPanel (vertical - ItemsPanelTemplate)
        • StackPanel (horizontal - DataTemplate)
          • TextBlock (column 1 – fixed width)
          • TextBlock (column 2 – fixed width)
          • TextBlock (column 3 – fixed width)
    If you don't need borders or there will never be enough data to warrant scrolling you can leave those elements out. You may need to consider a ViewBox to handle different aspect ratios as any rough table with fixed width columns is not going to play nicely with layout changes.
    • Marked as answer by Min ZhuMember Thursday, January 24, 2013 7:49 AM
    Tuesday, January 15, 2013 2:27 AM

All replies

  • There is indeed no DataGrid(View) in WinRT.

    With the present standard widget collection, the closest you can come is using a ListView with fixed [different] column sizes and whose Header mimics the column headers. Styling and templating capabilities for the individual 'rows' are quite powerful. But it remains an 'approximation'.

    Otherwise, you'll have to resort to 3rd party widget providers for WinRT.

    • Proposed as answer by Dave SmitsMVP Monday, January 14, 2013 9:23 AM
    • Marked as answer by Min ZhuMember Thursday, January 24, 2013 7:49 AM
    Monday, January 14, 2013 6:39 AM
  • Thanks for your suggestion . . can you suggest any 3rd party widget ? I need a table view for my stopwatch app, which shows lap time and overalltime . .
    Monday, January 14, 2013 10:00 PM
  • If you only need a basic table and don't want to mess with 3rd party controls, it's easy enough to create a mock table. For some basic tables in my apps, I used an ItemsControl inside a ScrollViewer. You need to be content with fixed column widths however. The header was also more of an illusion that sat above of the items control. It's far from an elegant solution but it's reasonably simple and looks ok. I haven't tried using controls derived from ItemsControl for making a table so I can't say if they make things easier or harder.

    Here's a rough outline:.

    • Border
      • StackPanel (horizontal)
        • TextBlock (column 1 – fixed width matching first element in data template)
        • TextBlock (column 2 – fixed width matching second element in data template)
        • TextBlock (column 3 – fixed width matching third element in data template)
    • ScrollViewer (with border)
      • ItemsControl
        • StackPanel (vertical - ItemsPanelTemplate)
        • StackPanel (horizontal - DataTemplate)
          • TextBlock (column 1 – fixed width)
          • TextBlock (column 2 – fixed width)
          • TextBlock (column 3 – fixed width)
    If you don't need borders or there will never be enough data to warrant scrolling you can leave those elements out. You may need to consider a ViewBox to handle different aspect ratios as any rough table with fixed width columns is not going to play nicely with layout changes.
    • Marked as answer by Min ZhuMember Thursday, January 24, 2013 7:49 AM
    Tuesday, January 15, 2013 2:27 AM
  • can you provide a sample app how many times i create a bind error of row 
    • TextBlock (column 1 – fixed width) 
    • with header
    • TextBlock (column 1 – fixed width matching first element in data template
    • so please post a sample dummy data please
    Monday, July 29, 2013 7:36 AM