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. Combobox causes lock up

Combobox causes lock up

Scheduled Pinned Locked Moved WCF and WF
csharpdatabaselinqquestion
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I have a Combobox that is bound to an observable collection. Upon the View being opened the collection is filled with a Linq to SQL. If I use a combobox it seems to lock up the app entirely. However, simply switching to a Listbox all is well. Why is this? Is there a work around other than using the Listbox with set sizes etc.?

    "9 Pregnent woman can not have a baby in 1 month" -Uknown

    C 1 Reply Last reply
    0
    • L Lost User

      I have a Combobox that is bound to an observable collection. Upon the View being opened the collection is filled with a Linq to SQL. If I use a combobox it seems to lock up the app entirely. However, simply switching to a Listbox all is well. Why is this? Is there a work around other than using the Listbox with set sizes etc.?

      "9 Pregnent woman can not have a baby in 1 month" -Uknown

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I'd assume a listbox is static and that your combobox is refreshing it's data source every time you open it. Perhaps you need to revisit how your data source is written ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      L 1 Reply Last reply
      0
      • C Christian Graus

        I'd assume a listbox is static and that your combobox is refreshing it's data source every time you open it. Perhaps you need to revisit how your data source is written ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        It does not do a continual refresh. Meaning, once my collection is populated thats it... This is code from a Context object

        SCADADataContext _scada = new SCADADataContext();
        ObservableCollection _allMOs;

            public string SelectedMO { get; set; }
        
            public ObservableCollection AllMOs
            {
                get
                {
                    if (\_allMOs == null)
                        FillAllMOs();
        
                    return \_allMOs;
                    
                }
            }
        
            private void FillAllMOs()
            {
                List availableMO = new List();
                var MOs = \_scada.MOs.Select(i => i.Name).Distinct().OrderBy(n => n);
                foreach (var mo in MOs)
                    availableMO.Add(mo);
                \_allMOs = new ObservableCollection(availableMO);
            }
        

        I then exchange this object in various VMs to get the info and expose the AllMOs to the View which is what I bind the combobox to or list box... Here is some of the VM code..

        public ObservableCollection AllMOs
        {
        //This will intiate a one time query into SCADA
        get { return _context.AllMOs; }
        }

        And lastly here is what resides in the View [ListBox DockPanel.Dock="Top" Grid.Column="1" ItemsSource="{Binding Path=AllMOs}" SelectedItem="{Binding Path=SelectedMO}" /> If I switch Listbox to Combobox it locks up...

        "9 Pregnent woman can not have a baby in 1 month" -Uknown

        I 1 Reply Last reply
        0
        • L Lost User

          It does not do a continual refresh. Meaning, once my collection is populated thats it... This is code from a Context object

          SCADADataContext _scada = new SCADADataContext();
          ObservableCollection _allMOs;

              public string SelectedMO { get; set; }
          
              public ObservableCollection AllMOs
              {
                  get
                  {
                      if (\_allMOs == null)
                          FillAllMOs();
          
                      return \_allMOs;
                      
                  }
              }
          
              private void FillAllMOs()
              {
                  List availableMO = new List();
                  var MOs = \_scada.MOs.Select(i => i.Name).Distinct().OrderBy(n => n);
                  foreach (var mo in MOs)
                      availableMO.Add(mo);
                  \_allMOs = new ObservableCollection(availableMO);
              }
          

          I then exchange this object in various VMs to get the info and expose the AllMOs to the View which is what I bind the combobox to or list box... Here is some of the VM code..

          public ObservableCollection AllMOs
          {
          //This will intiate a one time query into SCADA
          get { return _context.AllMOs; }
          }

          And lastly here is what resides in the View [ListBox DockPanel.Dock="Top" Grid.Column="1" ItemsSource="{Binding Path=AllMOs}" SelectedItem="{Binding Path=SelectedMO}" /> If I switch Listbox to Combobox it locks up...

          "9 Pregnent woman can not have a baby in 1 month" -Uknown

          I Offline
          I Offline
          Insincere Dave
          wrote on last edited by
          #4

          How many results are there? The listbox will use a VirtualizingStackPanel im not sure about the ComboBox, if there are lots of results or you have a complex DataTemplate that could cause a slow down. You may want to break with the debugger when it stalls and look at the call stack too.

          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