Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6797787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:39:07+00:00 2026-05-26T18:39:07+00:00

Due the nature of our software, we have to create our datagrid columns dynamically

  • 0

Due the nature of our software, we have to create our datagrid columns dynamically in code behind and add it then to the datagrid like this:

DataGridBoundColumn dataGridBoundColumn = new DataGridTextColumn
                                                          {
                                                              CellStyle = ...,                                                                            
                                                              Header = header,
                                                              Binding = binding
                                                          };
reportDataGrid.Columns.Add(dataGridBoundColumn);

Now we need a tooltip on the columnheader:

ToolTipService.SetToolTip(dataGridBoundColumn, "ENTER VALUE");

Well that works fine too. However I need to bind the tooltip’s value to a property on the ViewModel. I know how to do this in the xaml, but no idea how to do that in code.

Any help would be appreciated,

UPDATE:

Thanks to Steve’s answer I was able to fix this slightly differently:

Binding bindingBoundToTooltipProperty = new Binding()
                                   {
                                       Source = reportDataGrid.DataContext, 
                                       Path = new PropertyPath("ToolTipSorting")
                                   };


BindingOperations.SetBinding(dataGridBoundColumn, ToolTipService.ToolTipProperty, bindingBoundToTooltipProperty);

if the DataGridColumnHeaderStyle was customized, make sure to add these lines to the template as well:

<Trigger Property="IsMouseOver" Value="True">
    <Setter Property="ToolTip" Value="{Binding Column.(ToolTipService.ToolTip), RelativeSource={RelativeSource Self}}"/>
</Trigger>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:39:07+00:00Added an answer on May 26, 2026 at 6:39 pm

    You should be able to set up a binding as below:

    BindingOperations.SetBinding(dataGridBoundColumn,
        ToolTipService.ToolTipProperty,
        new Binding("Path.To.My.Property"));
    

    Note: the DataContext of this will be the value of the Header property on the column

    You want to bind to a property on the view model; assuming that your view model is the DataContext for the DataGrid you would want to change the binding to something like:

    new Binding("DataContext.ToolTipSorting")
    {
        RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor)
        {
            AncestorType = typeof(DataGrid)
        }
    }
    

    This attempts to locate the first parent object of type DataGrid and grab the value of its DataContext.ToolTipSorting property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We plan to implement our new system with Java. Due to the system's nature,
I am sure sure if this is even possible due to the nature of
Ok, I have an update function with a weird twist. Due to the nature
I have 2 sidebars on my site, and due to the nature of the
I have two class projects in a Visual Studio solution. Due to the nature
We have a collapsible tree implementation in our web app. I need to add
I have created a game in flash, and due to the nature of the
Due to the nature of the live server I deploy to, my mail settings
I am attempting to compile a c++ class using gcc. Due to the nature
I think I must be doing something stupid. Unfortunately, due to the nature of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.