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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:32:27+00:00 2026-05-28T06:32:27+00:00

I have a WPF application. In one window there is a combobox..and I want

  • 0

I have a WPF application. In one window there is a combobox..and I want to hide the toggle button and disable the combo box if there is only one item.

How would I achieve this ?

I have tried the below code for hiding the toggle button. But of no luck

Any help would be appreciated. thanks

<ComboBox x:Name="CList" ItemsSource="{Binding Path=C}"  >                    
    <Style TargetType="{x:Type ToggleButton}" >
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Items.Count, ElementName=CList}" Value="1">
                <Setter Property="Visibility" Value="Hidden" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</ComboBox>
  • 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-28T06:32:27+00:00Added an answer on May 28, 2026 at 6:32 am

    The better solution is to replace the template of combo box with a control template(which only contain textblock) when the item count is zero.

    Here is the xaml for the same.

    <ComboBox Name="CList" ItemsSource="{Binding Path=C}" 
                         SelectedItem="{Binding Path=CC}" VerticalAlignment="Center" Margin="0,0,10,0" >
                        <ComboBox.Style>
                            <Style TargetType="{x:Type ComboBox}" >
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=Items.Count, ElementName=CList}" Value="1">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <TextBlock Text="{Binding Items[0], ElementName=CList}" />
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ComboBox.Style>
                    </ComboBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF Windows application. In one window there is a particular stackpanel
I have WPF application with one main window . In this window there are
I have got a WPF Application, which contains a Window, inside it there is
My WPF application has more than one window, I want to attach some of
I have WPF Application where I have One main form and other user controls
This relates to Composite Application Guidance for WPF, or Prism. I have one MainRegion
I have a WPF application with the autocomplete box via the toolkit (VS 2008).
I have a WinForms application, and wanted to add some nice WPF controls, one
I have a wpf application using mvvm approach. The main window contains a tab
I am building a WPF application and I have some DependencyProperties in my window's

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.