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. Text and Image in header in listview

Text and Image in header in listview

Scheduled Pinned Locked Moved WPF
csharpwpftutorial
4 Posts 2 Posters 0 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.
  • K Offline
    K Offline
    krishnan s
    wrote on last edited by
    #1

    Hi, I need to display image and text together to the header in the Listview in wpf.Can u please let me know how to implement the same in wpf. Thanks

    M 1 Reply Last reply
    0
    • K krishnan s

      Hi, I need to display image and text together to the header in the Listview in wpf.Can u please let me know how to implement the same in wpf. Thanks

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      krishnan.s wrote:

      the header in the Listview

      ListView does't have a header. Are you referring to GridView? If so, you can set the HeaderTemplate on a GridViewColumn.

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      K 1 Reply Last reply
      0
      • M Mark Salsbery

        krishnan.s wrote:

        the header in the Listview

        ListView does't have a header. Are you referring to GridView? If so, you can set the HeaderTemplate on a GridViewColumn.

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        K Offline
        K Offline
        krishnan s
        wrote on last edited by
        #3

        Ya its the grid view iam referring too . Iam ale to display onlyone at a time , either text or image, Iam not getting how to display both together.Can u please let me know how to display both image and text in the single header cell. Thanks

        M 1 Reply Last reply
        0
        • K krishnan s

          Ya its the grid view iam referring too . Iam ale to display onlyone at a time , either text or image, Iam not getting how to display both together.Can u please let me know how to display both image and text in the single header cell. Thanks

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          krishnan.s wrote:

          Iam ale to display onlyone at a time , either text or image, Iam not getting how to display both together

          Use a panel that can host more than one element. Here's an example using a StackPanel:

          <ListView x:Name="booksListView" ItemsSource="{Binding Source={StaticResource BooksData}, XPath=\*}" >
              <ListView.View>
                  <GridView AllowsColumnReorder="False" >
                      <GridViewColumn Width="100" DisplayMemberBinding="{Binding XPath=@ISBN}" >
                          `<GridViewColumn.HeaderTemplate>                         <DataTemplate>                             <StackPanel Orientation="Horizontal">                                 <TextBlock Text="Header Text" />                                 <Image Source="images/Silverlight_Logo.jpg" />                             </StackPanel>                         </DataTemplate>                     </GridViewColumn.HeaderTemplate>`
                      </GridViewColumn>
                      <GridViewColumn Header="Title" Width="140" DisplayMemberBinding="{Binding XPath=Title}" />
                      <GridViewColumn Header="Summary" Width="140" DisplayMemberBinding="{Binding XPath=Summary}" />
                      <GridViewColumn Header="Price" Width="35" DisplayMemberBinding="{Binding XPath=price}" />
                      <GridViewColumn Header="Stock" Width="35" DisplayMemberBinding="{Binding XPath=@Stock}" />
                  </GridView>
              </ListView.View>
          </ListView>
          

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          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