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. Binding Tooltip to template element

Binding Tooltip to template element

Scheduled Pinned Locked Moved WPF
wpfwcftutorialquestion
5 Posts 3 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.
  • B Offline
    B Offline
    Blikkies
    wrote on last edited by
    #1

    Hey guys, I have added a TextBlock in one of my ItemTemplate, How can I bind the element parent's tooltip text to my TextBlock text for example:

    I know this is wrong, because the tooltip uses ToolTipService. Thanks

    P V 2 Replies Last reply
    0
    • B Blikkies

      Hey guys, I have added a TextBlock in one of my ItemTemplate, How can I bind the element parent's tooltip text to my TextBlock text for example:

      I know this is wrong, because the tooltip uses ToolTipService. Thanks

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

      There's nothing wrong with your sample there. That works perfectly well, assuming that MyParent is accessible to SubText.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      B 1 Reply Last reply
      0
      • P Pete OHanlon

        There's nothing wrong with your sample there. That works perfectly well, assuming that MyParent is accessible to SubText.

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        B Offline
        B Offline
        Blikkies
        wrote on last edited by
        #3

        I've try it but no luck, "MyParent" is a ListBox control, i have created a DataTemplate where SubText TextBlock is in and i've tried to bind the lisbox tooltip to the subtext text but failed Miserably.

        P 1 Reply Last reply
        0
        • B Blikkies

          I've try it but no luck, "MyParent" is a ListBox control, i have created a DataTemplate where SubText TextBlock is in and i've tried to bind the lisbox tooltip to the subtext text but failed Miserably.

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

          Why not just bind the tooltip in MyParent to the same element you are binding to as SubText?

          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

          1 Reply Last reply
          0
          • B Blikkies

            Hey guys, I have added a TextBlock in one of my ItemTemplate, How can I bind the element parent's tooltip text to my TextBlock text for example:

            I know this is wrong, because the tooltip uses ToolTipService. Thanks

            V Offline
            V Offline
            vinodkrebc
            wrote on last edited by
            #5

            Hi You can create a custom control based on what control you are using as parent. If you are using ListBox it would be like below

            public class CustomListBox : ListBox
            {
            public object ToolTip
            {
            get
            {
            return ToolTipService.GetToolTip(this);
            }
            }
            }

            You xaml will look like below

            <local:CustomListBox ItemsSource="{Binding Path=CustomerList}"
            ToolTipService.ToolTip="Your Tooltip"
            x:Name="lstParent">
            local:CustomListBox.ItemTemplate
            <DataTemplate>
            <TextBlock Text="{Binding Path=ToolTip, ElementName=lstParent}" />
            </DataTemplate>
            </local:CustomListBox.ItemTemplate>
            </local:CustomListBox>

            Let me know if it works. http://www.exploresilverlight.com Cheers! Vinod

            Vinod

            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