HybridScrollFrame

The HybridScrollFrame is a FrameXML-provided frame that is used by the UI to display large collections of items/object but without creating a new frame for each.

XML listview item template                  <Anchor point="CENTER" x="0" y="0"/> </Anchors> </FontString> </Layer> </Layers> </Frame> </UI>

lua listview item template mixin HybridScrollFrameItemMixin = {} function HybridScrollFrameItemMixin:SetSubject(subject) self.Subject:SetText(subject) end

addon file -- create a table of items local items = {} for i = 1, 10 do    table.insert(items, {         Subject = "Subject "..i,     }) end -- create the hybrid scroll frame local hsf = CreateFrame("ScrollFrame", "MyScrollFrame", UIParent, "HybridScrollFrameTemplate") hsf:SetPoint("CENTER", 0, 0) hsf:SetSize(200, 300) hsf.items = items -- add a scroll bar hsf.ScrollBar = CreateFrame("Slider", "$parentScrollBar", hsf, "HybridScrollBarTemplate") hsf.ScrollBar:SetPoint("TOPLEFT", hsf, "TOPRIGHT", 1, -16) hsf.ScrollBar:SetPoint("BOTTOMLEFT", hsf, "BOTTOMRIGHT", 1, 12) -- this will create listview items using the template define, the number of buttons is determined by the HybridScrollFrame_CreateButtons(hsf, "HybridScrollFrame_Item", 0, 0, "TOP", "TOP", 0, 0, "TOP", "BOTTOM") -- this is the update function, this will be called by the HybridScrollFrameTemplate, all that needs doing here is mapping your data to the buttons hsf.update = function local items = hsf.items; local buttons = HybridScrollFrame_GetButtons(hsf); local offset = HybridScrollFrame_GetOffset(hsf); local buttonHeight; for buttonIndex = 1, #buttons do        local button = buttons[buttonIndex] local itemIndex = buttonIndex + offset buttonHeight = button:GetHeight -- set the button height var to use in the update call later if itemIndex <= #items then local item = items[itemIndex] button:SetSubject(item.Subject) end end HybridScrollFrame_Update(hsf, #hsf.items * buttonHeight, hsf:GetHeight) end