code behind late binding

gorc65

New member
Joined
Jul 22, 2020
Messages
1
Programming Experience
10+
Hello.

I'm working on app that will show a lot of information from database to user to be reviewed. Many data has prest values stored in tables, combo box will be used.

What is the proper way to late-fill combo box list items just before list is opened, I need kind of "OnDropDown" event to be trigged?

Similary, I have data organized in TabControl. I've noticed that getters are called for each tab on creation of tab control. Is there some way to trig geters only when and if user will look at the tab?

Thx gorc
 
Welcome to the forums.

Show us what way you've gone about it and what relevant code you have now? Maybe suggestions can be made based of what you've already done.

If posting code, please use the code tags provided by the editor.
 
What is the proper way to late-fill combo box list items just before list is opened, I need kind of "OnDropDown" event to be trigged?

Similary, I have data organized in TabControl. I've noticed that getters are called for each tab on creation of tab control. Is there some way to trig geters only when and if user will look at the tab?
Yes. Implement your getters using Lazy<T>.

So instead of:
C#:
class MyViewModel
{
    ExpensiveObject BoundObject { get { return new ExpensiveObject(); }  }
}
you would have:
C#:
class MyViewModel
{
    Lazy<ExpensiveObject> _expensiveObject;
    ExpensiveObject BoundObject => _expensiveObject.Value;

    public MyViewModel(...)
    {
        :
        _expensiveObject = new Lazy<ExpensiveObject>(() => new ExpensiveObject());
    }
}
 
I think I've posted a few models around this website over time if you can be bothered to search up some of my examples for ideas on writing your own. I'd encourage you to write your own, and not copy mine. But you may get some ideas from them. Similarly wrote out examples like what Skydiver posted above. If you already got your own code, lets see it?
 
Back
Top Bottom