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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:54:25+00:00 2026-05-15T12:54:25+00:00

In the past, I developed a customized combo box in win forms which implements

  • 0

In the past, I developed a customized combo box in win forms which implements auto complete behavior where the matched portion of the text is highlighted in blue, whilst the rest of the string has the normal background color. In win forms this can be done fairly simply using OwerDraw mode. I need to do similar kinds of things for WPF controls. I know that in WPF templates can be used to customize how controls are displayed but as templates are declarative in nature I’m not sure how this would work – I need to change the way the text is drawn based on the internal state of the control. I realize I will to do some reading to figure this out but as WPF is a big topic I’d appreciate some pointers in the right general direction so I know where to start looking.

  • 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-15T12:54:26+00:00Added an answer on May 15, 2026 at 12:54 pm

    In WPF, look of the control is performed by a combination of templates, styles and sometimes style selectors. If you want to change the look of a control based on the state of some data (it could be internal or external to the control, it doesn’t really matter), then you can bind style values to this data and when it changes, the look of the control changes (provided that there is a notification mechanism to communicate the change). You can also transform data values by way of types called value converters (IValueConverter).

    As a simple example, we can change the text style of the text block based on an underlying data value:

    // In a C# class
    public class MyState : INotifyPropertyChanged
    {
         public bool IsEmphasized
         {
             get { return _isEmphasized; }
             set 
             { 
                 if (_isEmphasized == value) 
                 { 
                     return; 
                 } 
    
                 _isEmphasized = value;
                 OnPropertyChanged("IsEmphasized"); // This is how to notify that the data is updated
         }
    }
    
    
    // A converter
    public class BooleanToBoldConverter : IValueConverter
    {
        public Object ConvertTo(Object value)
        {
            if (value is bool)
            {
                 if ((bool)value)
                 {
                     return FontWeights.Bold;
                 }
                 else 
                 {
                     return FontWeights.Normal;
                 }
            }
        }
    }
    
    <TextBlock DataContext="{Binding Source={StaticResource myStateInstance}}" 
               FontWeight="{Binding IsEmphasized, Converter={StaticResource BooleanToBoldConverter}}" Text="Text" />
    

    While this is a simple example, and some details are elided, the main idea here to understand is that we can drive the UI from data values bound to properties and styles in a declarative way. We don’t need to do the actual drawing.

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

Sidebar

Related Questions

I have an Out-of-process COM server executable which was developed using Visual Studio 6.0
I have been a .net developer for the past three yrs. Just curious to
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
In past I use dynamic sql and datatable to get data from database. Such
Over the past few years I've changed from having a long flowing page of
In the past I've never been a fan of using triggers on database tables.
For the past few weeks, I've been trying to learn about just how email
In the past, some of my projects have required me to create a movie
In the past I've worked with a number of programmers who have worked exclusively
Over the past year or so my production platform has been plagued by an

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.