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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:30:02+00:00 2026-05-13T15:30:02+00:00

I need to put data from two different datasourses in the same textbox. The

  • 0

I need to put data from two different datasourses in the same textbox. The text that comes from the first one have to be bolded and the secound normal.

It’s there a possibility to do this in WPF?

  • 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-13T15:30:02+00:00Added an answer on May 13, 2026 at 3:30 pm

    You cannot bind (or multibind) to Document property of RichTextBox, because it is NOT a DependencyProperty (strange!!!)!!! See this link for a really easy way of subclassing RichTextBox to create your own BindableRichTextBox or this post for another workaround.

    Now you can use MultiBinding with a custom IMultiValueConverter to achieve the results. Since you have not given much details of your problem, I can only give you an overall idea of what you should do:

    <!--NOTE: Include xmlns:local=" .. " appropriately for your project-->
    <Window.Resources>
        <sys:String x:Key="SourceA">This text will be normal..</sys:String>
        <sys:String x:Key="SourceB">This text will be Bold!!!</sys:String>
    </Window.Resources>
    

    And now you can do like this:

    <local:BindableRichTextBox>
        <!--<local:BindableRichTextBox.Document>-->
            <MultiBinding Converter="{x:Static local:MySourceBToBoldConverter.Instance}">
                <Binding Source="{StaticResource SourceA}" />
                <Binding Source="{StaticResource SourceB}" />
            </MultiBinding>
        <!--</local:BindableRichTextBox.Document>-->
    </local:BindableRichTextBox>
    

    And then create a class MySourceBToBoldConverter that inherits from IMultiValueConverter like this:

    public class MySourceBToBoldConverter : IMultiValueConverter
    {
        public static readonly MySourceBToBoldConverter Instance = new MySourceBToBoldConverter();
    
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //Now you'll get value from Source A as value[0]
            //           and value from Source B as value[1]
            //Do whatever you want like bold etc...
            //and return the result
    
            string normalText = values[0] as string;
            string boldText = values[1] as string;
    
            Bold bold = new Bold();
            bold.Inlines.Add(boldText);
    
            Paragraph para = new Paragraph();
            para.Inlines.Add(normalText);
            para.Inlines.Add(bold);
    
            FlowDocument rtbDocument = new FlowDocument();
            rtbDocument.Blocks.Add(para);
    
            return rtbDocument;
        }
    
        public object[] ConvertBack(object value, ... )
        {
            //Convert the object returned by Convert() back 
            //to its original form if it's possible;
            //otherwise throw not supported exception ;)
    
            throw new NotImplementedException();
        }
    }
    

    Currently I don’t have my work PC with me that has VS installed, so I can’t give you a working example, but go ahead and search google/msdn/stackoverflow 4 MultiBinding and IMultiValueConverter and you’ll find some good examples out there.

    Check the working example here.

    Regards,
    Mihir Gokani

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

Sidebar

Related Questions

I have a C# program that selects data from two different database files and
I have two combobox. I need get some value from first combobox1 after combobox1
I need to extract data from a structure and put it into a list,
I need to put together a data structure that will efficiently provide keyword search
I need to map two different classes to the same view and receive an
I have related data living on two completely separate databases, and I need information
I'm trying to get data from one database and put it in the format
So I have two servers. SER1, SER2. SER1 is the one from where I
I have two listbox in windows Form c#, the first one has all valid
I'm trying to write an application in C# that will analyze two different data

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.