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 644929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:26:48+00:00 2026-05-13T21:26:48+00:00

How can I prefix bound values in TextBlock controls in a StackPanel without using

  • 0

How can I prefix bound values in TextBlock controls in a StackPanel without using separate controls for the prefixes?

E.g., let’s say I have a dialog that uses a TreeView to display a list of books, with the top nodes being the title, and a set of subordinate nodes for the other book attributes (ISBN, Author, etc.).

I have the binding working correctly, but my user wants the book attributes list to stack vertically, and, obviously, he wants each attribute node to have a descriptive prefix before the value (e.g., “Author: Erich Gamma” instead of just “Erich Gamma”). Inside my HDT and DT elements, I am using a StackPanel and TextBlock controls to display the values.

Must I use a separate TextBlock control for the prefix of each attribute

<!-- Works, but requires 2 controls to display the book author and the prefix stacks above the author -->
<TextBlock Text="Author: "/><TextBlock Text="{Binding Path=Author}" />  

or is there a way to do this with a single TextBlock control for each node?

<!-- only one control, but doesn't work -->
<TextBlock Text="Author:  {Binding Path=Author}" />  

I know this must be a common issue, and I Googled for it and searched in the three WPF books I have, but I guess I don’t know the right way to search for what I’m trying to say.

Thanks!

  • 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-13T21:26:48+00:00Added an answer on May 13, 2026 at 9:26 pm

    If you have .Net 3.5 SP1, you can easily achive this via StringFormat

    <TextBlock Text="{Binding Path=Title, StringFormat= Title: {0}}" />
    

    You can also do this

    <TextBlock>
      <TextBlock.Text>
        <MultiBinding StringFormat="Author: {0}, Title: {1}">
          <Binding Path="Author"/>
          <Binding Path="Title"/>
        </MultiBinding>
      </TextBlock.Text>
    </TextBlock>
    

    If you are not using SP1,
    Then you can use a ValueConverter

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

Sidebar

Related Questions

Can I order my users in the database, so I don't have to say
Let’s say I have test_23 and I want to remove test_ . How do
How can I remove the author prefix on a WordPress website, I have done
When using Doctrine::generateYamlFromDb(), can I specify a prefix to use? For example, if the
In Python, I can prefix an r to a string literal (raw string) to
Can I prefix all the Liferay tables that it initially creates by doing some
In IPv6, the prefix length can range from 0-128. What is the significance of
I'd like to remove the dbo prefix from the Object Explorer so I can
in routing.yml I can ressource other routing configs with: AcmeTestBundle: resource: @AcmeTestBundle/Resources/config/routing.xml prefix: /
Can anyone let me know how can we change the value of kendo combobox

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.