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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:03:49+00:00 2026-05-18T11:03:49+00:00

I have a combobox and button on my form. The combobox has categories in

  • 0

I have a combobox and button on my form. The combobox has categories in them. I want to allow/disallow pending on if they are a ‘system category’ based on a boolean.

Here is my xaml:

<Window.Resources>
    <Style TargetType="{x:Type ComboBox}">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip"
                Value="{Binding RelativeSource={RelativeSource Self}, 
                       Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>

This is the stack panel with the two controls in them:

                <StackPanel Grid.Column="1" Grid.Row="1">
                    <Label Content="Delete Category" Height="28"/>
                    <ComboBox x:Name="comboBox_DeleteCategory" 
                              Grid.Row="1" 
                              Height="29"                                  
                              ItemsSource="{Binding Path=CategorySelected.Items, ValidatesOnDataErrors=true, NotifyOnValidationError=true}"
                              SelectedItem="{Binding Path=CategorySelected.SelectedItem ,ValidatesOnDataErrors=True, NotifyOnValidationError=true}" 
                              DisplayMemberPath="Name"/>
                    <Button Content="Delete" Height="25" Margin="0,5,0,0" HorizontalAlignment="Right" Width="103.307" Command="{Binding DeleteCommand}"/>
                </StackPanel>

I am trying to get the combobox to show a tooltip if it is determined that it is a system category.

The DeleteCommand is working fine so I am not having issues with the button being disabled when I get a hit on the system category.

This is my code to show the tooltip:

#region IDataErrorInfo Members

public string Error { get; set; }

public string this[string columnName]
{
  get
  {
    Error = "";
    switch (columnName)
    {
      case "comboBox_DeleteCategory":
        if (CategorySelected.SelectedItem != null && CategorySelected.SelectedItem.IsInternal)
        {
            Error = CategorySelected.SelectedItem.Name + " is an system category and cannot be deleted.";
            break;
        }
        break;

    }

    return Error;
  }
}

#endregion

Any suggestions?

Thanks,

Eroc

  • 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-18T11:03:50+00:00Added an answer on May 18, 2026 at 11:03 am

    The indexer (public string this[string columnName]) is called with the property name that has been changed by the latest binding update. That is, filtering for “comboBox_DeleteCategory” (the control name) won’t help here. You have to filter for the property that was updated by the control’s binding and determine if it is in the expected state. You can put a breakpoint in the indexer and watch the columnName’s value. What is more, the Error property is not used by WPF at all. Thus, it is not necessary to set it. A simple example:

    public class Contact : IDataErrorInfo, INotifyPropertyChanged
    {
         private string firstName;
         public string FirstName
         {
             // ... set/get with prop changed support
         }
    
         #region IDataErrorInfo Members
    
         public string Error
         {
             // NOT USED BY WPF
             get { throw new NotImplementedException(); }
         }
    
         public string this[string columnName]
         {
            get 
            {
                // null or string.Empty won't raise a validation error.
                string result = null;
    
                if( columnName == "FirstName" )
                {
                    if (String.IsNullOrEmpty(FirstName))
                         result = "A first name please...";
                    else if (FirstName.Length < 5)
                         result = "More than 5 chars please...";
                 }
    
                return result;
        }
    }
    
    #endregion
    

    }

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

Sidebar

Related Questions

I have a combobox in a form and a button. I want to add
i have a form that consist of two textfield and one combobox. i want
All, I have a simple windows form with a combobox and a 'OK' button.
I have a form that has two buttons, textbox, listbox, and a combobox. The
I have a basic form with a combobox, a textbox, and a button on
I have a combobox whose value I want to use with a SQL WHERE
I have a combobox that passes along values in text, but they can have
Background I have a Windows Form with the following items: ComboBox TextBox Two Buttons
I have a combobox on a web form. The user can select a single
I have two comboboxes on an form. Each has the values Yes and No.

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.