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

  • SEARCH
  • Home
  • 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 7495455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:08:59+00:00 2026-05-29T18:08:59+00:00

I have Datagrid which is bound to my Database <WpfToolkit:DataGrid Name=DataGrid1 Grid.Row=1 ItemsSource={Binding Path=MainSearchBinding}

  • 0

I have Datagrid which is bound to my Database

<WpfToolkit:DataGrid Name="DataGrid1" Grid.Row="1" 
      ItemsSource="{Binding Path=MainSearchBinding}" />

And I have row details which is bound to the Intro column of my table in database

<WpfToolkit:DataGrid.RowDetailsTemplate>            
    <DataTemplate>
        <StackPanel Orientation="Horizontal" Margin="5">
                <StackPanel Orientation="Vertical" Margin="5" >
                    <TextBlock Foreground="CadetBlue" FontSize="13" 
                    Width="Auto" TextWrapping="Wrap" 
                    Text="{Binding Path=Intro}"/>

            </StackPanel>
        </StackPanel>
    </DataTemplate>
</WpfToolkit:DataGrid.RowDetailsTemplate>

What I want is not to use Intro column in my table. I want to use string value from my code instead of column Intro. How can I bind string value to my row details? Thanks in advance.

  • 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-29T18:09:00+00:00Added an answer on May 29, 2026 at 6:09 pm

    I modified my xaml code a little bit add Name to Text Block.

    <WpfToolkit:DataGrid.RowDetailsTemplate>
    
                    <DataTemplate>
    
                        <StackPanel HorizontalAlignment="Stretch" Orientation="Vertical" Margin="5">
                            <TextBlock Foreground="CadetBlue" FontSize="14"
                                TextWrapping="Wrap" Name="rowdetails" HorizontalAlignment="Stretch"
                                />
                        </StackPanel>
                    </DataTemplate>
    
    
                </WpfToolkit:DataGrid.RowDetailsTemplate>
    

    And the in code behind I add this code below to OnMouseClick. retString is my string variable. It is showing my string variable in each clicked row details.

     Microsoft.Windows.Controls.DataGridRow row = (Microsoft.Windows.Controls.DataGridRow)(DataGrid1.ItemContainerGenerator.ContainerFromItem(DataGrid1.SelectedItem));
    
                // Getting the ContentPresenter of the row details
                DataGridDetailsPresenter presenter = FindVisualChild<DataGridDetailsPresenter>(row);
    
    
                DataTemplate template = presenter.ContentTemplate;
                TextBlock txt = (TextBlock)template.FindName("rowdetails", presenter);
                txt.Text = retString;
    

    Do not forget to add FindVisualChild in your code. Here is the code.

    private childItem FindVisualChild<childItem>(DependencyObject obj)
        where childItem : DependencyObject
            {
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
                {
                    DependencyObject child = VisualTreeHelper.GetChild(obj, i);
                    if (child != null && child is childItem)
                        return (childItem)child;
                    else
                    {
                        childItem childOfChild = FindVisualChild<childItem>(child);
                        if (childOfChild != null)
                            return childOfChild;
                    }
                }
                return null;
            }
    

    I do not know why nobody answered to my question. Maybe it is not popular.

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

Sidebar

Related Questions

I have a DataGrid which is being bound dynamically to a database query. The
I have a DataGrid in my WPF window which is bound to a database.
I have a Silverlight 4 DataGrid which has its ItemsSource bound to an ObservableCollection
I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
I have a datagrid which is bound to a database table. I need to
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
I have a DataGrid which I am binding to a PagedCollectionView which is grouped
I have a wpf datagrid which is bound to an observable collection. Currently I
I have a silverlight datagrid which is bound to a PagedCollectionView displaying a collection
I have a View that displays a DataGrid which is bound to an ObservableCollection

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.