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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:23:23+00:00 2026-05-23T01:23:23+00:00

I have a ComboBox whose xaml is as follows <ComboBox Name=ComboBoxDiscussionType IsEnabled={Binding ElementName=ComboBoxDiscussionType, Path=Items.Count,

  • 0

I have a ComboBox whose xaml is as follows

<ComboBox Name="ComboBoxDiscussionType" IsEnabled="{Binding ElementName=ComboBoxDiscussionType, Path=Items.Count, Converter={StaticResource ComboBoxItemsCountToBoolConverter}}"/>

and the converter takes the Items.Count and checks if its greater than 0 if its greater than 0 then enable it else disable it

The goal is enable the ComboBox if the ComboBox only if it has Items in it else disable it,
( self Binding to its item.count )

the following is my converter,

public class ComboBoxItemsCountToBoolConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (int)value > 0;
    }
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return null;
    }
}

how do i achieve it? right now the above Binding gives me an error

  • 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-23T01:23:24+00:00Added an answer on May 23, 2026 at 1:23 am

    For reasons that I don’t understand, on Silverlight the value as seen by the converter is of type double but it should be int. In fact it is an int on WPF.

    But since this is the case, just processing it as a double fixed the problem:

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (int)(double)value > 0;
    }
    

    Strangely enough, a more traditional relative source binding doesn’t work either:

    <Binding RelativeSource="{RelativeSource Self}" .../>
    

    but your original element name binding does:

    <ComboBox Name="ComboBoxDiscussionType" IsEnabled="{Binding ElementName=ComboBoxDiscussionType, Path=Items.Count, Converter={StaticResource ComboBoxItemsCountToBoolConverter}}"/>
    

    This seems pretty buggy to me, but Silverlight is a strange beast sometimes.

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

Sidebar

Related Questions

I have a ComboBox whose XAML looks as follows: <StackPanel Grid.Row = 0 Style={DynamicResource
I have a ComboBox with 2 items whose contents are databound to 2 dependency
I have a combobox whose value I want to use with a SQL WHERE
I have a ComboBox, whose ItemsSource is bound to a new (not default) ListCollectionView,
I have a combobox that is binding to an ObservableCollection of strings in an
I have a combobox from which i need to programmatically disable items depending on
I have a combobox in Access 2003 whose recordset is obtained from a stored
(I'm using Cairngorm) I have a combobox that displays items form an XMLListCollection that's
As you see I have class whose name is table; and I have many
Suppose I have a ComboBox with name, myComboBox . Now, if I declare another

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.