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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:11:47+00:00 2026-05-18T08:11:47+00:00

In my WPF application, I would like to display something that looks like this:

  • 0

In my WPF application, I would like to display something that looks like this:

User Bob has logged off at 22:17.

Where “Bob” and “22:17” are data-bound values.

The obvious way to do this would be to use a StackPanel with multiple TextBlock children, some of them data bound:

<StackPanel Orientation="Horizontal">
   <TextBlock Text="The user"/>
   <TextBlock Text="{Binding Path=Username}" TextBlock.FontWeight="Bold" />
   <TextBlock Text="has logged off at"/>
   <TextBlock Text="{Binding Path=LogoffTime}" TextBlock.FontWeight="Bold" />
</StackPanel/>

This works, but it’s ugly. The program is supposed to be localized to different languages, and having separate strings for “The user” and “has logged off at” is a recipie for localization disaster.

Ideally, I would like to do something like this:

<TextBlock>
     <TextBlock.Text>
         <MultiBinding StringFormat="{}The user <Bold>{0}</Bold> has logged off at <Bold>{1}</Bold>">
             <Binding Path="Username" />
             <Binding Path="LogoffTime" />
         </MultiBinding>
</TextBlock>

So the translator would see a complete sentence The user <Bold>{0}</Bold> has logged off at <Bold>{1}</Bold>. But that doesn’t work, of course.

This has to be a common problem, what’s the right solution for this?

  • 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-18T08:11:48+00:00Added an answer on May 18, 2026 at 8:11 am

    I’ve never tried to do something like this before, but if I had to I would probably try and use a Converter that takes the MultiBinding and breaks it up and returns a StackPanel of the pieces

    For example, the binding would be something like:

    <Label>
         <Label.Content>
                 <MultiBinding Converter={StaticResource TextWithBoldParametersConverter}>
                     <Binding Source="The user {0} has logged off at {1}" />
                     <Binding Path="Username" />
                     <Binding Path="LogoffTime" />
                 </MultiBinding>
        </Label.Content>
    </Label>
    

    And the Converter would do something like

    public class TextWithBoldParametersConverter: IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            // Create a StackPanel to hold the content
            // Set StackPanel's Orientation to Horizontal 
    
            // Take values[0] and split it by the {X} tags
    
            // Go through array of values parts and create a TextBlock object for each part
                // If the part is an {X} piece, use values[X+1] for Text and make TextBlock bold
                // Add TextBlock to StackPanel
    
            // return StackPanel
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to display a 3D model in a WPF application (the model
I would like my WPF application to display all percentages without % sign. For
there is some default functionality on a WPF application that i would like to
I would like to display a WPF window from a windows forms application (.NET
I have a WPF application with several windows. I would like to define GLOBAL
I'm porting my application from Winforms+XNA to WPF (+ XNA?) and I would like
I recently wrote, my first, WPF application that has a list of items that
I am working on a WPF application that needs to display several video streams
I am currently working on this application(C#,WPF,LINQ2XML,.NET 4.0) that displays details for 'Animals'. An
I have an application that needs to display a grid of data consisting mostly

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.