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 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 WPF window from a windows forms application (.NET
In a WPF application I would like to implement the following behaviour which doesn't
I am writing a wpf destop application, and would like to use SQL Server
I recently wrote, my first, WPF application that has a list of items that
We're designing a WPF / MVVM application that allows the user to search and
I would like to make my WPF application fullscreen. Right now the start menu
I have a WPF application , and I would like to modify the background
I have two strings in a C# WPF application and would like to generate
I would like to do some processing of images in a WPF application. However,
I have created a wpf application ,there are two canvas i would like to

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.