Computer systems are important tools used by various people in many different ways. Computer applications are executed on computer systems. These computer applications are software programs, typically written by application developers, compiled into object code, and then stored on the various computer systems for operation. The creation and use of computer applications is a well-known aspect of computer technology in general.
When creating a computer application, the developer typically chooses a particular environment or platform on which the application will ultimately be executed. For example, when writing an application, the developer will choose the Microsoft Windows® platform, the Linux platform, or some other platform. As a result of this choice, the program developer may have different options available for writing the application.
As an example, the typical platform provides a user interface display engine that receives commands and information from the application during runtime and responds by displaying that information on a user interface device, such as a computer monitor. Thus, the application developer must create or program the application to make the right call to the platform, which hopefully causes the platform to respond by displaying the right data in the right format when desired. Often, the presentation of the data consumes large amounts of critical resources, which results in a perceptible performance degradation of the computer system. In accordance with the present invention, the use of critical resources is reduced.
The present invention is directed towards systems and methods for virtualizing a user interface. In particular, the present invention relates to providing access to a large amount of data while consuming a relatively small amount of a critical resource. The user interface is virtualized by allocating a critical resource to a relatively small subset of the accessed data at a particular time. For example, virtualization in accordance with the present invention can be applied to an “ItemsControl” control. The “ItemsControl” control can be used to create UI subtrees for those items that are currently visible on the screen, and to discard the subtrees that have gone out of view.
In one aspect of the invention, a computer system having an operating system platform comprises a user interface framework system for rendering data according to a visual style defined for the data type. The user interface framework system comprises a store of objects, wherein the objects have one or more data fields, a generator that is configured to generate a visual representation of the objects based on style definitions, and a display panel that is configured to measure a limited display area, determine a number of objects that can be displayed within the limited display area, and to prompt the generator to generate visual representations of the number of objects that can be displayed within the limited display area.
According to another aspect of the invention, a method renders data according to a visual style defined for the data type. The method comprises storing objects, wherein the objects have one or more data fields, measuring a limited display area, determining a number of objects that can be displayed within the limited display area, and generating a visual representation of the objects for the number of objects that can be displayed within the limited display area.
A more complete appreciation of the present invention and its improvements can be obtained by reference to the accompanying drawings, which are briefly summarized below, and to the following detailed description of presently preferred embodiments of the invention, and to the appended claims.
Throughout the specification and claims, the following terms take the meanings explicitly associated herein, unless the context clearly dictates otherwise. The terminology and interface specifications used herein are not intended to represent a particular language (or platform) in (or for) which a particular object or method should be written. Rather, the terminology and interface specifications are used to describe the functionality and contents of an interface or object, such as function names, inputs, outputs, return values, and what operations are to be performed using the interface (or what operations are to be performed by the object).
Illustrative Operating Environment
With reference to
The computer system 100 displays information, such as display screen 102. The display screen 102 is enlarged to show details of the display. The display 102 relates to a simplified (for clarity) display of an example company application used to manage different portions of a business such as employee information. Although display 102 displays employee content information, many other types of content may be managed and displayed in accordance with the present invention. Accordingly, the employee example is not meant as a limitation, but merely as an illustration.
In the figure, the display 102 has a title bar 104 and an employee window 106. There may be other windows for managing other information as indicated by scroll bar 108. Employee window 106 has a title bar 110 and a tool bar 112. Tool bar 112 provides user controls such as a search control 114 and an “add employee” control 116, among potentially many others. Such user interface controls are generally known in the art and are useful in managing certain types of information.
Within employee window 106, there may be two sub-windows, such as employee list window 118 and employee detail window 120. In this particular example, employee window 118 displays a list of all the employees working for ABC Company. In a particular embodiment, as discussed in more detail below, each set of employee information may be a distinct object stored in a database or other datastore. As an object, e.g., of class “Employee,” each has a set of properties. For example, the properties for each employee may include a name property, an address property and an employee identification value or ID property. The exemplary window 118 displays four employee objects 122, 124, 126 and 128 and has been designed to display these three properties associated with each employee object. Although four employee objects are represented in the list window 118, many more may be shown as indicated by the ellipses 130 and the scroll bar 132.
In order to create the employee window 118, a developer of the application may utilize a list control. In an embodiment, the application used to display the window 118 was created for the operating system platform developed by Microsoft Corporation. In such a case, the use of a control such as “ListBox” or others may be implemented to generate the window 118. ListBox, as well as other controls such as menu controls, are given the ability to manage a collection of items of arbitrary type.
The details window 120 will be discussed in more detail below, but in general, the details window 120 displays more object properties for a highlighted object, such as the Mark Jones object shown in
The present invention relates to the associating of objects, such as the employee objects represented by
In addition to the memory 204, the system 200 may include at least one other form of computer-readable media. Computer readable media, also referred to as a “computer program product,” can be any available media that can be accessed by the system 200. By way of example, and not limitation, computer-readable media might comprise computer storage media and communication media.
Computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Memory 204, removable storage 208 and non-removable storage 210 are all examples of computer storage media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by system 200. Any such computer storage media may be part of system 200.
The exemplary computing system 200 may also contain a communications connection(s) 212 that allow the system to communicate with other devices. The communications connection(s) 212 is an example of communication media. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. The term computer readable media as used herein includes both storage media and communication media.
In accordance with an embodiment, the system 200 includes peripheral devices, such as input device(s) 214 and/or output device(s) 216. Exemplary input devices 214 include, without limitation, keyboards, computer mice, pens, or styluses, voice input devices, tactile input devices and the like. Exemplary output device(s) 216 include, without limitation, displays, speakers, and printers. Each of these “peripheral devices” is well know in the art and, therefore, not described in detail herein.
With the computing environment in mind, embodiments of the present invention are described with reference to logical operations being performed to implement processes embodying various embodiments of the present invention. These logical operations are implemented (1) as a sequence of computer implemented steps or program modules running on a computing system and/or (2) as interconnected machine logic circuits or circuit modules within the computing system. The implementation is a matter of choice dependent on the performance requirements of the computing system implementing the invention. Accordingly, the logical operations making up the embodiments of the present invention described herein are referred to variously as operations, structural devices, acts or modules. It will be recognized by one skilled in the art that these operations, structural devices, acts and modules may be implemented in software, in firmware, in special purpose digital logic, and any combination thereof without deviating from the spirit and scope of the present invention as recited within the claims attached at the end of this specification.
User Interface Elements
Referring now to
An application module 302 developed in accordance with the present invention is shown in
In a particular exemplary embodiment, the objects 306 may be managed as a set of similar objects in an object collection 307. An example may be an object collection relating to employee objects and therefore each object has the same properties or fields as the other objects. Of course the content of these properties or fields is different for different employee objects. In other embodiments, there may be other types of objects 309, such as customer objects as part of another collection 311 within the same datastore 304. The other types of objects have different properties or fields. For example, the employee objects have an employee ID value wherein the customer objects do not. Similarly, the customer objects may have an account number property where the employee objects do not. Those skilled in the art will recognize that there are many different potential types of objects having many different properties.
The application module 302 also accesses or is associated with style definitions 310. The style definitions may be developed or designed by the developer of the application module 302 or the definitions 310 may be created by a third party. The style definitions relate to the actual style properties to be associated with the data content of the objects 306 when the data is ultimately displayed. These data specific styles are shown as data style 315. A data style is stored separately from the data objects and is relatively independent of the data itself. A data style influences the display of data in two principal ways: (1) by specifying property values for the item itself, and (2) by specifying an internal representation for the item, e.g., a visual subtree. For instance, style definitions may include font size (such as 12 or 10 point, etc.), type (such as Arial or Courier, etc.), color (such as black or red, etc.), attributes (such as bold or italics, etc.), location (such as position on the display), etc. Also, the style also describes a visual subtree to aid in the creation of an internal visual representation of the items, such as for a given data object which fields should be displayed. The visual tree is discussed in more detail below.
Moreover, the style definitions may be sub-divided into separate style definitions for each of the properties of each object to be displayed. In a particular embodiment, a style definition may be stored for each class of objects. For example, the employee class of objects may have its own predetermined style definition and the customer class of objects may have is own, unique predetermined style definition. However, as discussed below, in an alternative embodiment, one style definition may be used for objects of different types.
The style definitions 310 may also contain list control style information 317 which provides visual style information for the list control itself, independent of the data to be displayed in the list control. That is, there may be a significant amount of user interface information regarding the building of a list on a display including size information, border information, shading and color information, how the user interacts with the list, such as mouse interaction, etc. The list control style 317 is used to provide such information.
In an embodiment, the application module 302 has a data binding section 312 that, during operation, causes data items 309, i.e., properties of the data objects 306, to be ultimately bound to the UI elements or properties of a style definition such as definition 315. The data binding section 312 relates to the declarative program statement(s) that associates one or more data objects to a data style. Such an association may be made by explicitly identifying the data types and the data style for that type, or by providing a style selector call, or by providing a default style, or by some other method.
Application module 302 operates on platform 314. Platform 314 relates to the framework or application programming interface (API) that provides the necessary communication between the application module 302 and the operating system of the computer, such as computer 100 shown in
Within the platform 314, a tree assembler module 318 parses the information received from the application module 302 in order to build a “visual tree” which is an internal representation of the display and thus represents the combination of the data from the objects 306 to be displayed and the information from the style definitions that describes how to display the data. The visual tree is described in more detail below in conjunction with
In an embodiment, the tree assembler 318 receives the data content and the style information directly from the application module 302. In other embodiments, the tree assembler 318 may access the required content and style information directly from the datastore 304 and the definition module 310, respectively, through the operation of the data bind module 321. In doing so, the tree assembler 318 understands where to look and what to find based on the binding information received from the application's data bind section 312.
The tree assembler module 318 completes the visual tree and passes the tree to the rendering engine 320. In an embodiment, the tree is passed relatively directly to the rendering engine 320, which, in turn uses the visual tree to render the display on the user interface display 316. However, in an alternative embodiment, the visual tree is passed first to a layout engine 322 that adds more information to the visual tree, using user interface elements from factory 324 to complete the tree. The layout engine, in an embodiment understands the physical properties of the display such that it can determine where to place certain display items and how large to make them relative to the physical characteristics of a particular computer system.
Of course, the application module 302 and the tree assembler module 318 operate in a dynamic environment wherein the tree assembler may make an initial visual tree and as the application 302 runs, items and displays may change, such that the tree assembler 318 may rewrite or modify the visual tree to ultimately update the display.
A listing of some exemplary markup language, e.g., XAML code is provided in
As may be appreciated, many other user interface elements may also be built into the example style for employees. For simplicity, the exemplary style 408 is primarily concerned with displaying three primary employee fields in a particular order. This however, should not be considered a limitation as many other fields could be displayed, in many different orders, along with many other types of user interface elements (images, buttons, sliders, etc) As may be appreciated, the styled display is not limited to text.
An exemplary visual tree 500 is shown in
The first item in visual tree portion 500 is the list box item 504. In essence, when building the tree, the tree assembler, such as tree assembler 318 shown in
Next the tree assembler creates the UI for the data items, one at a time, and adds it to the visual tree underneath the panel 505. This UI comes from two places. The first piece comes from the list control itself. In the example shown in
The visual tree 508 typically contains a special element that indicates where the UI for the data item belongs. In one embodiment, this special element is a ContentPresenter 510. This is where the second piece of UI is added. The tree assembler performs an inquiry to determine the style information for the data item. It creates a copy of the visual tree described in that style, and adds it to the main visual tree at position 512. Thus the content presenter functions to “style” the data content.
The content presenter acts to retrieve the first object and upon receiving the object, such as an employee object, the tree assembler uses the defined item's style to layout the proper fields in the visual tree. For instance, the first element in the EmployeeStyle 408 is a Dock Panel command, such that a dock panel entry 512 is made in the visual tree. Next, with the dock panel, the EmployeeStyle requires that text be displayed, and the first text element be the name from the first employee object. The actual text is not placed here. Instead a binding is made here in order to account for later changes made to the actual data, i.e., when the data changes in the data item, the data associated with the visual tree 500 will also change. Next, text entries 516 and 518 are inserted into the visual tree to account for the lines 412 and 414 shown in
This process is repeated for all the employee objects, such that sub-trees 520, 522 and 524 are entered into the visual tree. Upon completing the visual tree 500, the tree 500 may be passed to a layout engine, such as engine 322 (
Initially, receive operation 602 receives a request to display data from a set of objects. The set of objects may be related in that each object is of the same type or the same class, but this is not necessary. Upon receiving the request to display data from the data objects, parse operation 604 parses the request. In parsing the request, parse operation 604 identifies that a list is to be displayed and determines whether any style should be applied to the list. Further, parse operation 604 iterates over the list of items and determines if any particular styles should be applied to the data items themselves.
In an embodiment, the request to display the data also includes some kind of style information. In essence, the style information causes requests, at runtime to the platform to establish links between the data and the associated styles. In establishing the appropriate links, a search operation may be performed to search for and locate the appropriate style.
Upon establishing the appropriate links, apply operation 606 applies any defined styles for the data objects. Although the style is described independently of the data, apply operation determines the necessary user interface elements to apply from the style such that a visual tree data structure may be built or modified. The modified visual tree may include some kind of binding information. This information causes requests at runtime to the platform to establish links between the properties of the UI elements and the properties of the data items. These requests may be declarative, i.e., interpreted by the platform, or procedural, i.e., the application, such as application 302 (
In applying the defined style, flow 600 incorporates enter operation 608 which enters visual information into a visual tree. Enter operation 608 receives the results of the apply operation 606. That is, each data object is essentially associated with some style information, defined independently from the data itself. Enter operation 608 assembles the result of apply operation 606, including any links (bindings) as described above, and stores the information into a data structure, i.e., the visual tree. The visual tree has visual information for the all the data (and other user interface elements) to be displayed. Essentially, the application module 302 makes requests to the data bind module 321 to make these links. As stated above, these requests may be declarative, i.e., interpreted by the tree assembler module 318, or procedural, i.e., the application 302 calls the binding methods at runtime. Moreover, the data styles, such as style 315 may also have a declarative request for binding to data as well. In such a case the data bind module 321 handles these requests too.
Next, pass operation 610 passes the visual tree to the layout engine and rendering engine to apply more style information (if necessary) and to ultimately render the display items on a display device. Upon rendering the display, flow 600 ends at end operation 612.
Flow 700, shown in
Initially, flow 700 begins with apply operation 702 which first recognizes that a list item is to be displayed. Consequently, since the object is a list item, apply operation determines the particular list-item style that should be applied. The list-item style relates to an independently defined set of user interface elements that apply to list-items in general, and independently from the actual data to be presented/displayed in the list. For example, the list-item style may define the background color for the list item or how the user may interact with the list item.
Next, as part of the list item display process, the content presenter is invoked at operation 704, which, in turn provides the indication that a data item is to be displayed. In an embodiment, as the list item display process is progressing, at some point a content presenter action or command is received. This command identifies the actual data object that has the data for display. Next, get style operation 706 gets the style associated with first list item. Get operation 706 is the result of invoking the content presenter, which identifies the object collection and the object to be retrieved, along with information regarding the appropriate or relevant visual style. Once the appropriate style is selected, apply operation 708 applies the appropriate style to the content presenter and inserts the visual information into the visual tree, such as tree 500 shown in
Determine operation 712 determines whether all the objects have been entered into the visual tree. If there are more objects to add to the visual tree then flow branches YES to operation 702. Operation 702 repeats the process of applying a list item style to the visual tree. Next operation 702 gets content presenter operation 704 which, in turn causes get operation 706 to get the next style associated with the next data item. As may be appreciated, flow 700 is repeated for each object until all objects have been evaluated and their visual representations have been entered into the visual tree. In an alternative embodiment, the determine operation 712 may take other items into account before causing the repetition of flow 700. That is, the determine operation 712 may determine at any time, for any reason, to stop adding visual elements to the visual tree. For example, the determine operation may determine that enough user interface elements have been created to fill the available space such that flow 700 should end at end operation 714. Alternatively, determine operation may determine that a time threshold limit has been exceeded such that no more objects should be added to the visual tree.
When determining which style to apply to the data content, e.g., operation 708 described above in conjunction with
In another embodiment, the list box request may not provide the item style information and instead may provide only the item source information as shown in line 802 of code snippet 800 shown in
In yet another embodiment, the style information is identified using an “ItemStyleSelector” object in the list box request as shown in line 902 of code snippet 900 shown in
In order of priority, in an embodiment, the tree assembler looks for an explicit reference first, then determines whether a style selector has been identified when no explicit style references is indicated. Next, if neither an explicit style reference nor a style selector has been identified, the tree assembler identifies the type of object and searches for a style based on the object type, such as described in conjunction with
The operations described above depend on many different things, such as the collection of items, the values of the properties within the collection of items, the style information, the style selector information, the styles defined for the controls, e.g. the list box control and the list item control, etc. Each of the various elements that help make up the display components may, in fact, change dynamically. The platform, such as platform 314 (
For instance, during the execution of the application, a new object may be added to the object collection, such as object collection 306 shown in
Similarly, when an item is removed from the object collection, the tree assembler module may be notified. The tree assembler module determines the relevance of the removal and, if relevant removes the corresponding user interface elements from the visual tree and thus rebuilds the visual tree. Again, the new tree is passed to the rendering engine for display rendering.
In an embodiment, another type of collection change relates to a “refresh.” That is, in some cases most, if not all, of an object collection may change in some way. For example, when an application module, such as application 302 (
When the item style property is changed, a notification is sent to the tree assembler module as well. In some cases the item style may have been used in styling many different objects such that the tree assembler module must determine whether changes are relevant and where. If relevant, a re-styling in all the necessary locations occurs potentially resulting in a new user interface being displayed according to the new style. Accordingly, the same process occurs when the item style selector property changes as well.
Flow 1000 begins with invalidate operation 1002 which invalidates the visual tree. In essence, since the visual tree is an internal representation of the data to be displayed and since that data has changed due to a change to the object collection or to the defined styles, the visual tree is no longer valid. Such an invalidation step may involve the setting or clearing of a bit to indicate that the present visual tree is no longer valid.
Next recognize operation 1004 recognizes that the tree is no longer valid. Such recognition may relate to the tree assembler module being notified of the invalidation operation, or the tree assembler module may listen for the type of event.
Upon recognizing that the visual tree is no longer valid, then determine operation 1006 determines if the change is relevant. Determine operation 1006 relates to the evaluation of the change and a comparison against the current display to determine if the change would cause a change in the current display. If not, then flow branches NO to end operation 1008. If the change is relevant, then flow branches YES to rebuild operation 1010. In one embodiment, rebuild operation 1010 begins rebuilding the entire visual tree as described above, in order to capture the change. In other embodiments, the rebuild operation simply identifies where the visual tree should change and makes those changes. Upon rebuilding the tree, the tree is passed to the rendering engine to cause the actual presentation of the display, i.e., the re-rendering of the display. As before, the tree may be passed to a layout engine for added user interface elements prior to passing to the rendering engine. Upon passing to the rendering engine, flow ends at operation 1008. As may be appreciated, upon rebuilding the visual tree, the tree is then “validated” such that when another change is made, the tree can again be invalidated to restart the flow 1000.
In an embodiment of the current invention, application module, such as module 302 (shown in
To further illustrate this example, assume the field of the Name property is bound to data object for Mark Jones using: “<Text TextContent=“*Bind(Path=NameField)”>” as the command. Since the display command calling the salary information is bound to the actual data record, as soon as a change is made to the data record, the same change is shown in the details window. Similarly, a change in the details window will cause a change in the master window 118, since its information is also bound to the actual data records.
User Interface Virtualization
As referenced above in
If the list of items in the data store 304 is large (e.g., 3,000 or more), the cost can become prohibitive. However in most situations, only a small number of these subtrees (e.g., 50 subtrees) are actually visible to the user, with the rest being accessible by using a scrollbar 132 or similar control to bring a new subset of items into view. In accordance with the present invention, virtualization is used to create UI subtrees only for those items that are currently visible on the screen, and to discard the subtrees that have gone out of view. The virtualization process is typically driven by a layout component, because the layout component “knows” what is being displayed to a user.
In accordance with the present invention, a virtualized user interface comprises three components. A control (e.g., “ItemsControl,” as described in
The layout process can be envisioned as a traversal of an element tree. During the traversal, each element is measured to determine its size, and then arranged such that the element occupies a position within the panel. Measuring an element typically involves recursively measuring the child element of the element.
The panel for an items control initially has no children. The children for the panel 322 are typically created on demand with help from a generator. When panel 322 is first measured, the generator 330 is prompted to prepare for requests, which typically starts with the first item. The generator 330 is then repeatedly prompted to realize (i.e., generate a user interface subtree) the next item, by adding the resulting user interface subtree to its own list of child elements. Optionally, the panel can measure the new subtree recursively. A simple panel may continue this until it has exhausted all the items in the list. A more sophisticated panel may choose to stop when enough user interface elements are generated to fill the available space in the panel, and/or when the time limit is reached, and/or for any other reason.
Additional user interface elements are generated when a user asks to see more items (such as by moving a scrollbar 132). The panel 322 is measured once again, and determines that it needs to generate more user interface elements. Assuming, for example, the panel 322 can display 20 items in a limited display area 1210, the panel 322 signals the generator 330 to prepare (with a different starting point such as the 21st item), then repeatedly asks the generator to realize items until the 20 display spaces are filled with items. At the same time, the panel 322 can identify items having a realized UI display that is no longer needed, remove the UI from its own list of children, and signal the generator to mark (and/or deconstruct) those items as “unrealized.”
The process of user interface virtualization is (typically) controlled by the panel 322. Because an application author can easily replace the panel used by the control with another panel (by changing the control's style, for example), it is possible to obtain different virtualization behaviors while using the same control.
As another example, a simple panel may do no virtualization, but rather just realize all the items. Another panel may do “deferred realization” by realizing items only when they come into view, but never discarding the UI for items that leave view of the display. Yet another panel may do full virtualization, discarding the UI for out-of-view items.
Flow 1300 begins with operation 1310 which creates a wrapper (i.e., an item UI). Usually this means creating an instance of the control's ItemUIType. In some circumstances, the generator can use the item itself as the wrapper (without creating a new wrapper). The circumstances include whether the item already has the right type (or a subtype), and/or the control did not specify an ItemUIType and the item is already a UI element. When the control does not specify an ItemUIType and the item is not a UI element, the generator creates a wrapper of some default type, such as ContentPresenter.
In operation 1320, style information is propagated from the control to the new wrapper, as described above with reference to
The generator typically returns the wrapper to the panel, which adds it as a child. When the panel measures its children, the wrapper will usually be expanded to a full subtree of UI elements by applying the usual styling rules.
Coordinates can be used to facilitate communication between the generator in the panel. The generator and the panel often need to refer to a particular position, such as “the first item” or “the 100th unrealized item following the 35th realized item”. They can do so using a two-level coordinate system of the form (index, offset). The two components can be integers with the following meanings:
To start the initial generation from the beginning of the list, the panel typically uses the position (−1, 0). The 100th unrealized item following the 35th realized item would accordingly be described by the position (34, 100), where the index is 0-based so that the 35th item has index 34.
During a scroll-down operation, the panel typically needs to append wrappers to its list of children, which correspond to the newly visible items. If for example the panel presently has 20 (realized) children, it could ask the generator to start at position (19, 1), which is the first unrealized item after the 20th realized one. Note that the form of this position does not depend on how many unrealized items come before the 20 realized children of the panel. This format relieves the panel of the responsibility of knowing the position (in the items collection) of its realized children.
Likewise, when a new item is inserted into the collection, the generator can notify the panel using the position (15, 36), meaning “the 36th unrealized item following the item corresponding to the (panel's) child with index 15.” The panel can then determine whether the new item should be realized.
ItemsControls and their users often need to map between an item and the corresponding UI element, or vice-versa. Similarly they may need to map between the index of the item (which is the item's position in the list of all items) and the corresponding UI element, or vice-versa. Performing these mappings requires knowledge of which items have been realized, and where they appear relative to unrealized items.
Typically, only the generator has this knowledge. Accordingly the generator exposes methods to do the mappings mentioned above. It also can expose a method to find the ItemsControl that was responsible for generating a given UI element. An element that handles a mouse click, for example, can use this to forward the click to the parent items control.
Note that virtualization implies that items do not necessarily have any corresponding UI. For unrealized items, the mapping methods return null. Controls can be written to handle this case, if they are to participate in virtualization.
When items are inserted or removed from the items collection, or when the collection is re-sorted or otherwise rebuilt in a fundamental new way, the corresponding UI is updated or replaced in response. Replacement is relatively straightforward—the existing UI can be simply discarded and the generation (i.e., “de-virtualization”) process started over with the new list of items.
Insertion can be handled as follows. The collection raises a change event, to which the generator responds. The generator updates its internal data structure to account for the presence of a new unrealized item, and then raises the ItemsChanged event, which indicates the position of the new item relative to existing realized items. The panel (whether virtualizing or not) responds to this event and determines whether the new item needs an updated UI. A non-virtualizing panel will typically need an updated UI, but a virtualizing panel may determine that no update for the UI is needed because the item is out of view. If an update for the UI is needed, the panel can call back into the generator to create a new UI, using the position supplied in the ItemsChanged event.
Removing an item is handled similarly. The collection raises a change event, which is received by the generator. In response, the generator typically updates its internal data structure to remove any reference to the item. The generator also raises the ItemsChanged event to inform the panel about the change, supplying the correct position. The panel is typically responsible for actually removing the UI generated for a realized item from its tree.
As a further illustration of the present invention, APIs for UI virtualization are given below. In an embodiment, the APIs are provided in the Controls namespace within an operating system of a computer system.
Using the above systems and methods, an application author can provide many different and flexible styling techniques to data used in the application. The defined styles can be used for one or more different objects, in accordance with aspects of the present invention. Importantly, the application author can assign style information in a declarative manner, i.e., the above systems and methods provide a declarative way to program how data looks when displayed and how an end user might interact with the user interface elements and underlying data. In doing so, the data is separated from the user interface elements and style definitions. Consequently, the author or an end user may change the data objects without changing the user interface elements. Likewise, the author may adjust the user interface elements without changing the data objects.
As may be appreciated, many different types of objects may be used in accordance with principles of the present invention, including but not limited to strings, list items, etc. Also, although many of the examples described above dealt with list items and list controls, many other collections of items may be managed and displayed according to principles of the present invention, including but not limited to menus, combo boxes, list boxes, etc. The present invention may be applied to work with any control that manages a collection of items. In an embodiment, the present invention works with all controls that derive from “ItemsControl” as part of the Microsoft Windows® framework. Also, although the invention has been described in language specific to structural features, methodological acts, and computer readable media containing such acts, it is to be understood that the invention defined in the appended claims is not necessarily limited to the specific structure, acts or media described. Therefore, the specific structure, acts or media are disclosed as preferred forms of implementing the claimed invention.