I've got a simple question, I've got a ComboBox
whose ItemsSource
is bound to a relatively expensive service call.
If I have the ComboBox
in question 开发者_StackOverflow社区disabled will the binding still fire? If so what I can I do to ensure that the expensive call is only made when it really needs to be?
You probably want to at least consider modifying the template for the ComboBox
so that it uses a VirtualizingStackPanel
, at least, as long as your service call fetches items one at a time. See this for a pretty good discussion of the issues.
Edit
To answer your actual question: no, disabling the ComboBox
doesn't stop it from populating its items. I determined this by implementing a collection class, binding a ComboBox
's ItemsSource
to an instance of it, and watching it service its method calls. Its items get retrieved if the ComboBox
is enabled. They even get retrieved if its Visibility
is Collapsed
. I'm pretty surprised; that's not what I would have expected at all.
精彩评论