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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:18:15+00:00 2026-05-23T02:18:15+00:00

I have a Textblock that is bound to a property in the ItemsSource collection.

  • 0

I have a Textblock that is bound to a property in the ItemsSource collection. I’d like to display two properties from that class in the same textblock, but it seems I can only perform one binding at a time.
I currently have this:

Text="{Binding Title}"

but I want I want to append another property, so in theory it would be:

Text="{Binding Title - Author}" 

with the output looking like “Shakespeare – Romeo and Juliet”. I’ve tried adding a comma, another binding and other things, but they all result in an exception being thrown (e.g. Unknown attribute Text on element TextBlock).

Both properties comes from the same class, so I won’t need to have two data sources.

  • 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-23T02:18:16+00:00Added an answer on May 23, 2026 at 2:18 am

    Unfortunately silverlight is missing a few pieces that WPF has that can handle this. I would probably go the route of using a value converter that you can pass the class that contains the Title and Author to format the text.

    Here’s the code:

    public class TitleAuthorConverter : IValueConverter
    {
    
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is Book)) throw new NotSupportedException();
            Book b = value as Book;
            return b.Title + " - " + b.Author;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    
    public class Book
    {
        public string Title { get; set; }
        public string Author { get; set; }
    }
    

    And some XAML:

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <local:Book Title="Some Book" Author="Some Author" x:Key="MyBook"/>
            <local:TitleAuthorConverter x:Key="Converter"/>
        </Grid.Resources>
        <TextBlock DataContext="{StaticResource MyBook}" Text="{Binding Converter={StaticResource Converter}}"/>
    </Grid>
    

    The downside to this way is that you won’t get the text to update if the properties change (ie you implement INotifyPropertyChanged) since the field is bound to the class.

    As suggested in the comments on the question, you could also create a third property that combines them. This would get around having to use multibindings or value converters.

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

Sidebar

Related Questions

I have a TextBlock that is bound to a DateTime property. How do I
I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
I have a user control that has a Title property bound to the Text
I have ItemsControl that is bound to collection of type Student. Inside the ItemTemplate
I have a TextBlock in my XAML that has its text bound to a
I have a textblock that is bound to an object. This object I have
I have a comboBox that is bound to a list of strings from my
I have a DataGridTemplateColumn that defines a TextBlock which has bound Background and Foreground
I want to have a fixed-width TextBlock that has long, unbroken, horizontal text, and
I have a WPF view that displays a Shipment entity. I have a textblock

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.