Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to add multiple column in a single column of gridview in WPF?

How to add multiple column in a single column of gridview in WPF?

Scheduled Pinned Locked Moved WPF
wpfcsharpcsswcfhelp
5 Posts 3 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bankey1010
    wrote on last edited by
    #1

    Hi All, I am able to add column into a gridview as follows: <ListView Name="listView1" ItemsSource="{Binding}" Margin="11,26,115,44"> <ListView.View > <GridView > <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" /> <GridViewColumn Header="Span Length" DisplayMemberBinding="{Binding Span Length}" /> </GridView> </ListView.View> </ListView > but i want to add multiple column into a single column in the abovew grid view i mean that, i have create some groups to show data into single gridview. can anybody help me how it is possible because i am new with xaml... Thanks Bankey

    P 1 Reply Last reply
    0
    • B bankey1010

      Hi All, I am able to add column into a gridview as follows: <ListView Name="listView1" ItemsSource="{Binding}" Margin="11,26,115,44"> <ListView.View > <GridView > <GridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" /> <GridViewColumn Header="Span Length" DisplayMemberBinding="{Binding Span Length}" /> </GridView> </ListView.View> </ListView > but i want to add multiple column into a single column in the abovew grid view i mean that, i have create some groups to show data into single gridview. can anybody help me how it is possible because i am new with xaml... Thanks Bankey

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Do you mean you want to show multiple bound items in a GridViewColumn? If so, you can bind multiple items into a data template like this:

      <DataTemplate>
      <TextBlock>
      <TextBlock Text="{Binding Path=...}" />
      <TextBlock Text="{Binding Path=...}" />
      </TextBlock>
      </DataTemplate>

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      L 1 Reply Last reply
      0
      • P Pete OHanlon

        Do you mean you want to show multiple bound items in a GridViewColumn? If so, you can bind multiple items into a data template like this:

        <DataTemplate>
        <TextBlock>
        <TextBlock Text="{Binding Path=...}" />
        <TextBlock Text="{Binding Path=...}" />
        </TextBlock>
        </DataTemplate>

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Here are two other ways you can do this. 1. Use a MultiValue Converter that concatenates the two strings and places the output in one TextBlock. I demonstrate this techniques in my article: http://www.codeproject.com/KB/WPF/WPFBusinessAppsPartThree.aspx[^]. This article also has the required value converter code and xaml usage. Look at the below xaml. See how the MultiBinding Converter syntax works, it takes muliple string values and binding them to one property. MultiBinding converters are a great WPF feature.

        <Core_WPF:FormNotification WatermarkMessage="New Record"
        Height="28" Panel.ZIndex="99" AutoCollapseTimeout="2">
        <Core_WPF:FormNotification.ErrorMessage>
        <MultiBinding Converter="{StaticResource formNotificationErrorMessageConverter}">
        <Binding Path="Error" />
        <Binding Path="ValidationExceptionErrors" ElementName="ucPartThree" />
        </MultiBinding>
        </Core_WPF:FormNotification.ErrorMessage>
        </Core_WPF:FormNotification>

        2. In addition to Pete's code of placing the two TextBlocks inside another TextBlock, you could also use a StackPanel as a container for the two TextBlocks.

        Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

        Just a grain of sand on the worlds beaches.

        P 1 Reply Last reply
        0
        • L Lost User

          Here are two other ways you can do this. 1. Use a MultiValue Converter that concatenates the two strings and places the output in one TextBlock. I demonstrate this techniques in my article: http://www.codeproject.com/KB/WPF/WPFBusinessAppsPartThree.aspx[^]. This article also has the required value converter code and xaml usage. Look at the below xaml. See how the MultiBinding Converter syntax works, it takes muliple string values and binding them to one property. MultiBinding converters are a great WPF feature.

          <Core_WPF:FormNotification WatermarkMessage="New Record"
          Height="28" Panel.ZIndex="99" AutoCollapseTimeout="2">
          <Core_WPF:FormNotification.ErrorMessage>
          <MultiBinding Converter="{StaticResource formNotificationErrorMessageConverter}">
          <Binding Path="Error" />
          <Binding Path="ValidationExceptionErrors" ElementName="ucPartThree" />
          </MultiBinding>
          </Core_WPF:FormNotification.ErrorMessage>
          </Core_WPF:FormNotification>

          2. In addition to Pete's code of placing the two TextBlocks inside another TextBlock, you could also use a StackPanel as a container for the two TextBlocks.

          Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

          Just a grain of sand on the worlds beaches.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Karl - that's the thing I really love about WPF. So many ways to solve the same problem, all of them flexible.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          L 1 Reply Last reply
          0
          • P Pete OHanlon

            Karl - that's the thing I really love about WPF. So many ways to solve the same problem, all of them flexible.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Pete O'Hanlon wrote:

            the thing I really love about WPF. So many ways to solve the same problem

            Me too! :cool:

            Cheers, Karl » CodeProject 2008 MVP » Microsoft MVP - Client App Dev My Blog | Mole's Home Page | MVP Profile

            Just a grain of sand on the worlds beaches.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups