Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. ComboBoxItem Question [modified]

ComboBoxItem Question [modified]

Scheduled Pinned Locked Moved WCF and WF
questionhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BlitzPackage
    wrote on last edited by
    #1

    Greetings, What is the best way to get a reference to a combobox item?   I want to make certain options within the combobox, while visible, unavailable to the user in a combobox based on selections made elsewhere.   So my plan is to get a reference to it, change the background color, and disable it. Can I do the following: ComboxBoxItem option = ComboBoxOptions.SelectedItem as ComboBoxItem; option.IsEnabled = false; option.Background = Colors.Gray; Also, if I have set the datacontext for the ListBox, can I listen to its "SourceUpdated" event? Thanks for any help you can provide.

    modified on Tuesday, December 29, 2009 7:38 PM

    A 1 Reply Last reply
    0
    • B BlitzPackage

      Greetings, What is the best way to get a reference to a combobox item?   I want to make certain options within the combobox, while visible, unavailable to the user in a combobox based on selections made elsewhere.   So my plan is to get a reference to it, change the background color, and disable it. Can I do the following: ComboxBoxItem option = ComboBoxOptions.SelectedItem as ComboBoxItem; option.IsEnabled = false; option.Background = Colors.Gray; Also, if I have set the datacontext for the ListBox, can I listen to its "SourceUpdated" event? Thanks for any help you can provide.

      modified on Tuesday, December 29, 2009 7:38 PM

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      BlitzPackage wrote:

      disable

      Try to bind the combo box's disabled property.

      BlitzPackage wrote:

      datacontext

      Use INotifyPropertyChanged along with the datacontext's source.

      There are only 10 types of people in this world — those who understand binary, and those who don't.

      B 1 Reply Last reply
      0
      • A Abhinav S

        BlitzPackage wrote:

        disable

        Try to bind the combo box's disabled property.

        BlitzPackage wrote:

        datacontext

        Use INotifyPropertyChanged along with the datacontext's source.

        There are only 10 types of people in this world — those who understand binary, and those who don't.

        B Offline
        B Offline
        BlitzPackage
        wrote on last edited by
        #3

        Thank you for your reply. While I would try to bind to the ComboBox's disabled property, I need the individual ComboBox items to be enabled or disabled based on user input in another control. Thanks for the second suggestion, I will pursue it or a variant thereof.

        A 1 Reply Last reply
        0
        • B BlitzPackage

          Thank you for your reply. While I would try to bind to the ComboBox's disabled property, I need the individual ComboBox items to be enabled or disabled based on user input in another control. Thanks for the second suggestion, I will pursue it or a variant thereof.

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #4

          BlitzPackage wrote:

          I need the individual ComboBox items to be enabled or disabled based on user input in another control

          You can bind to other controls. And if the logic is complex (e.g., enabled only if they enter an even number), you can use a class which implements IValueConverter or IMultiValueConverter to produce a bool from the values input by the user in one or more other controls. Also, if you bind the other control to a view model, you can then bind to that view model in the original control (i.e., two controls can bind to the same view model).

          [Forum Guidelines]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups