How to load content into dynamically created TabItems On-Demand/Lazy Load? - wpf

I have a tab control defined in my app and I'm adding tab items to it dynamically. Lets say I have list of objects with lots of data and for each object I show 5-10 tabs. The ordering and the tabs shown differ from object to object. That is why I have to dynamically create these tabs based on my object.
As far as the content inside these tab items go, I generally set the .Content property of each tab to a UserControl and it loads it as shown in below code.
If ContainsFingerprints() Then
Dim fingerprintT As New TabItem
fingerprintT.Content = New FingerprintTab()
fingerprintT.Header = "Fingerprints"
fingerprintT.Name = "tiFingerprintTab"
viewTab.Items.Add(fingerprintT)
End If
Some of these tabs have lots of images and take up lot of memory at run time. That is why I would like to load Content in those tab items 'on-demand', that is, only when the tab is selected.
I could use the SelectionChanged event of the tab control and then load the required content but is there a better solution that WPF offers?

Related

troubleshooting steps when React.memo() not working?

I have a component with some tabs. Each tab selector loads its own datagrid. After a tab has been selected and its datagrid has been loaded, the datagrid should be essentially cached so that toggling away and back to the tab should simply write out the previous datagrid that was loaded/cached. The datagrid entity that gets loaded for each tab/entity essentially looks like this:
<MyDataGrid entity={entity} />
I've wrapped the datagrid component definition with the memo() function like this:
const MyDataGrid = memo((props: IncludeListProps): React.ReactElement => {
debugger;
});
However, the debugger breakpoint is getting hit within the component every time. What is the sequence of steps that you would use to go about troubleshooting something like this?
UPDATE
Providing some additional info based on comments below. A tab strip on top refreshes the display div underneath. So yes the props of MyDataGrid change (eg props.entity.id).
But what I need to do is figure out the best way to cache/memoize each MyDataGrid created per tab. I'm thinking maybe a div collection where each div will be reserved to hold MyDataGrid for a specific tab. Then divs will display inline/none based on the current tab selection. Does this seem like the most straightforward approach?

How can I get back my lost Checkboxes (after moving them from the Form to the Panel)?

I placed several panels on my form. When I clicked the central panel in the designer, the main form was what was actually selected (even though the panel should be on top of it, and the main form should not be (easily) clickable in the designer).
By the way, clicking the other panels on the form don't have this problem (all of the other panels are on top of the form).
Because of the form being clicked when I expected that I was clicking the panel, when I added several controls to what I thought was the panel (after successfully adding some labels on top of the panel), all of these controls (checkboxes) ended up on the form / below the panel, so that they don't display at runtime:
When I realized that the controls were on the form, and not on the panel, I selected the form from the Property browser, selected all of the checkboxes at once, and cut the group of them.
I then selected the main panel from the Property Browser, and pasted those cut checkboxes onto the panel. It sort of worked, but all I saw was their outline (all selected together). I used the Ctrl+Up arrow to move them in a body up on the panel, a little at a time, until they were all near the top where they belong. But then they just disappeared.
From now on I will make sure to right-click the panel and select "BringToFront" before adding any controls to that area; for now, though, I don't see the checkboxes on either the form or the panel. How can I get them back (and place them on the panel), and prevent the form from ever appearing on top of the panel (except if/when I select it from the Property browser)?
The checkboxes do still exist, although their names were changed from "ckbxAll" etc. to Checkbox1, etc. They appear on the correct panel in Form1Designer.cs, but do not display. Here is how they are represented there:
// panelMain
//
this.panelMain.BackColor = System.Drawing.Color.White;
this.panelMain.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelMain.Controls.Add(this.checkBox21);
this.panelMain.Controls.Add(this.checkBox20);
this.panelMain.Controls.Add(this.checkBox19);
this.panelMain.Controls.Add(this.checkBox18);
this.panelMain.Controls.Add(this.checkBox17);
this.panelMain.Controls.Add(this.checkBox16);
this.panelMain.Controls.Add(this.checkBox15);
this.panelMain.Controls.Add(this.checkBox14);
this.panelMain.Controls.Add(this.checkBox13);
this.panelMain.Controls.Add(this.checkBox12);
this.panelMain.Controls.Add(this.checkBox11);
this.panelMain.Controls.Add(this.checkBox10);
this.panelMain.Controls.Add(this.checkBox9);
this.panelMain.Controls.Add(this.checkBox8);
this.panelMain.Controls.Add(this.checkBox7);
this.panelMain.Controls.Add(this.checkBox6);
this.panelMain.Controls.Add(this.checkBox5);
this.panelMain.Controls.Add(this.checkBox4);
this.panelMain.Controls.Add(this.checkBox3);
this.panelMain.Controls.Add(this.checkBox2);
this.panelMain.Controls.Add(this.checkBox1);
this.panelMain.Location = new System.Drawing.Point(160, 0);
this.panelMain.Name = "panelMain";
this.panelMain.Size = new System.Drawing.Size(639, 740);
this.panelMain.TabIndex = 2;
//
UPDATE
It turns out they ARE there, but they are invisible now (except for their outlines when I click on them):

complex grid layout in AngularJS

Am a newbie to AngularJS. I want to create a gridview layout where each item in the grid is a bit complex layout. For example, an item may have a text, an image and a button. This has to repeat several times over the entire data fetched from the DB & displayed as a grid. A rough sketch of what am saying :
in the above image, each item in the grid has an image & a text. Imagine each item also having two or three more buttons.
Google+ layout is also similar :
I can use ng-repeat, but I want a more nice solution (similar to GridView in the Android world). Also, I want to be able to change a specific item in the grid & reload only that item without reloading the entire grid.
Can someone please help?

Prism - Region with IActiveAware not called on initial load

I have regions within a TabControl that load fine when I click the tab headers but I cannot set a default view when the page initially loads.
Ex: If I have 3 tabs, I want the first one loaded by default. Easiest way to do this?
After InitializeComponent() in the constructor
TabControl.SelectedItem = TabControl.Items[0];
Did not test it though

How to make views visible and collapsed depending on whether the corresponding module is loaded or not?

I have a prism application already in production.
I need to create a new module in this application.The module can either exist on not exist in the application depending on the configuration file.
This module view should be dispalyed in a region already existing. The view should only be visible when the module is loaded.
Problem: the existing screen has a region showing 2 tab items from 2 different modules. Now the new view should be part of the first tab and it gives the user the option to select whether to view the previous info or the new info from this new module.
I am stuck and dont know how I am going to show these checkboxes when the new module is loaded and hide it when it is not. Where do I put this logic?
Current scenario:
Very vague images to define what i meant?
Here's an option that will work, and isn't too much effort...
Inside your beautifully illustrated Tab1, add another tab control, and make this a Prism region. Fill this region with both the original view, and the view from your new module.
Then, restyle the inner tab control, if necessary, so the tab headers appear like radio buttons, and set up a datatrigger to hide the tab header strip if the number if tabs is less than or equal to 1.
Thanks for all your help :)
After a lot of RND i figure it out.
I have created a two tabcontrol regions one for the main tab and the other for the child tab.
on the child tab i have return style to display tabitem only if item.count is more then 1 as suggested by mark.
and i have put this code in my existing module.

Resources