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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:54:09+00:00 2026-06-05T17:54:09+00:00

I have a custom textblock that has various text properties for left, right and

  • 0

I have a custom textblock that has various text properties for left, right and same text as dependency properties. I use “Run” for making them have different foreground colors. It was like this in a method inside the control:

Inlines.Add(new Run(_leftValue[i]) { Foreground = Brushes.Red });

I added a dependency property for brush. How can I set it in my custom control’s cs file?

Thanks in advance

  • 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-06-05T17:54:11+00:00Added an answer on June 5, 2026 at 5:54 pm

    You have given us precious little to go on, but I’ll give you an answer anyway. The format for setting a dependency proeprty is this:

    [instance of the dependency object].SetValue(YourDependencyObject.TheDependencyProperty, value);
    

    so for the example of a DP taking a brush, this should so it:

    this.SetValue(MyCustomControl.ForegroundBrush, Brushes.Red);
    

    Note that MyCustomControl is the literal name of your type, and this should be castable to a DependencyObject (if your control derives from Window, Control, FrameworkElement, etc. then it derives from DependencyObject).

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

Sidebar

Related Questions

I have a custom component, ExportCommandButton, that has two attached properties. This component is
I have a TextBlock that contains some text in some Run elements, and which
I have a custom dependency property that I would like to use as a
I have created a custom TaskButton control that takes an image and text. The
I have a ListBox that has a custom DataTemplate assigned to it, so that
I have a WPF Window that has a custom border, Thumb controls for resizing,
I have custom button, with an image that I'd like to shift down within
I have custom class that implement IEnumerable<int[]> interface and save current Enumerator . When
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have the following simple custom control that I have defined for a Windows

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.