Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
How to display tooltip for different records?
posted
Hi, I'm using an XML data source to populate my xamdatagrid. However, I have no idea how to get tooltips (which are part of the xml data source) to popup for each record whenever the cursor is hovering above it. Can some one give me a simple example? Or point me in the right direction? Thanks Josh
Parents
No Data
Reply
  • 1650
    posted

     I don't know whether it's the only way, but I would say you have to go with styles. Here is a short example that displays a tooltip for an image:

    <!-- visualizes the synchronization status of a given item -->
    <Style x:Key="ToolTipStyle"
           TargetType="{x:Type igDP:CellValuePresenter}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
            <StackPanel Orientation="Horizontal">
              <Image Source="{Binding ...}"
                     ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record.DataItem.EditStatus}"
                     Margin="2,0,2,0" />
             
              <ContentPresenter x:Name="PART_EditorSite"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
            </StackPanel>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

     

    In order to get the style working, bind it to a given field by setting the CellValuePresenterStyle:

    <igDP:Field Name="EditStatus" Label="Status">
      <igDP:Field.Settings>
        <igDP:FieldSettings AllowEdit="False"
                            CellValuePresenterStyle="{StaticResource ToolTipStyle}" />
      </igDP:Field.Settings>
    </igDP:Field>

     

    btw - you can also construct more complex tooltips that do not only consist of a simple string. Here's another sample of the tooltip in the above example that creates a StackPanel:

    <Image Source="{Binding ...}"  Margin="2,0,2,0">
      <Image.ToolTip>
        <ToolTip>
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="Editor Status: " />
            <TextBlock Margin="2,0,0,0" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record.DataItem.EditStatus}" />
          </StackPanel>
        </ToolTip>
      </Image.ToolTip>
    </Image>

    This produces something like this:


     

    HTH,

    Philipp 

Children