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