WPF-based multi-format content hybrid scrolling method, apparatus and device, and storage medium
By using the VisualBrush and DoubleAnimation components on the WPF platform to generate a mirror copy of the content, the animation container is driven to achieve adaptive multi-format content, multi-directional scrolling, and real-time updates. This solves the problem of limited functionality of multi-format scrolling controls in the WPF platform, and improves development efficiency and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-03-27
AI Technical Summary
The WPF platform lacks a native multi-format scrolling marquee control, and third-party controls have limited functionality, making it impossible to achieve adaptive multi-format content, multi-directional scrolling, and real-time data updates, resulting in low development efficiency and wasted resources.
By using a WPF-based method for mixed scrolling of multi-format content, a mirror copy of the content is generated using VisualBrush technology, and the DoubleAnimation animation component is combined to drive the animation-driven container, enabling adaptive scrolling of multi-format content, multi-directional scrolling, and real-time data updates.
It enables adaptive multi-format content, multi-directional scrolling, and real-time data updates, reducing resource consumption, improving development efficiency and user interaction experience, and lowering development and migration costs.
Smart Images

Figure CN121742736A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of WPF interface control, and particularly relates to a WPF multi-format content mixed scrolling method and device, equipment and a storage medium. BACKGROUND
[0002] WPF (Windows Presentation Foundation, Windows rendering foundation) is an interface development technology based on the.NET framework launched by Microsoft, and is widely used in desktop application development due to its powerful interface rendering capability and data binding characteristics. In the interface design of WPF application, the marquee control is a commonly used component for realizing data carousel and information scrolling display, and is often used in message notification, advertisement display, data broadcast and other scenes.
[0003] However, the WPF platform in the prior art has significant technical shortcomings: on the one hand, the WPF framework does not provide a native marquee control, and developers need to develop or integrate third-party controls; on the other hand, the existing third-party marquee control has a single function and can only support single-format scrolling of pure text or pure pictures, and cannot meet the scrolling display requirements of mixed text and pictures, custom function controls (such as buttons, progress bars, etc.). At the same time, the third-party control does not have adaptive scrolling determination capability, and will forcibly trigger scrolling regardless of whether the content size exceeds the display container, resulting in resource waste; and only supports single-direction scrolling, cannot adapt to up-down, left-right and other multi-directional display requirements, and does not support real-time updating of data-bound content, so developers need to write a large amount of repetitive code to realize content refreshing and scrolling control, which seriously reduces program development efficiency and cannot adapt to diversified interface display scenarios. SUMMARY
[0004] The present application provides a WPF multi-format content mixed scrolling method, device, equipment and storage medium, to solve the defects of no native multi-format scrolling marquee control in WPF, limited function of third-party control and low development efficiency in the prior art, and realize adaptive, multi-directional scrolling and real-time data updating of multi-format content.
[0005] The present application provides a WPF multi-format content mixed scrolling method, comprising:
[0006] According to the type of the content to be scrolled, the corresponding loading rule is adapted, and the content to be scrolled is loaded into a first scrolling container to obtain a second scrolling container, wherein the content to be scrolled includes at least one of text, pictures, mixed text and picture content, and custom WPF controls;
[0007] The display size parameter of the display container is obtained and compared with the actual size parameter of the second scrolling container;
[0008] When the actual size parameter is greater than the display size parameter, a mirror copy of the content to be scrolled in the second scroll container is generated by VisualBrush technology;
[0009] A new animation-driven container is created, and the second scroll container and the mirror copy are seamlessly spliced into the animation-driven container;
[0010] The animation-driven container is embedded into the display container;
[0011] The animation-driven container is driven to move based on a DoubleAnimation animation component, so that the second scroll container and the mirror copy in the animation-driven container are synchronously scrolled with the movement.
[0012] According to the WPF multi-format content mixed scrolling method provided by the application, the method further comprises:
[0013] Based on the NotifyPropertyChanged data binding mechanism, real-time association between the content to be scrolled in the second scroll container and a data source is established;
[0014] When the data source is changed, the refreshing of the content to be scrolled in the second scroll container is automatically triggered, so that the animation-driven container does not need to be re-driven.
[0015] According to the WPF multi-format content mixed scrolling method provided by the application, the comparison rule between the actual size parameter and the display size parameter comprises:
[0016] If the width of the second scroll container is greater than the width of the display container, it is determined as horizontal scrolling;
[0017] If the height of the second scroll container is greater than the height of the display container, it is determined as vertical scrolling;
[0018] If the width and the height of the second scroll container are both not greater than the width and the height of the display container, it is determined as static display.
[0019] According to the WPF multi-format content mixed scrolling method provided by the application, the method further comprises:
[0020] When the actual size parameter is not greater than the display size parameter, the second scroll container is embedded into the display container for static display.
[0021] According to the WPF multi-format content mixed scrolling method provided by the application, the loading rule comprises:
[0022] When the content to be scrolled is text, a TextBlock, TextBox or RichTextBox control is instantiated, font, font size and color attributes are configured, and then added to the first scroll container;
[0023] When the content to be scrolled is a picture, an Image control is instantiated, a picture source is bound, and a stretching mode and a scaling rule are set, and then added to the first scroll container;
[0024] When the content to be scrolled is a picture-text mixed layout, a sub-container is used to complete the combined layout of a text control and a picture control, and then the sub-container is added to the first scroll container as a whole;
[0025] When the content to be scrolled is a custom WPF control, a custom control is instantiated, business attributes are initialized, and an interaction event is bound, and then added to the first scroll container.
[0026] According to the WPF multi-format content mixed scrolling method provided by the application, before the DoubleAnimation animation component drives the animation driving container to move, so as to realize the synchronous scrolling of the second scroll container and the mirror copy in the animation driving container with the movement, the method comprises the following steps:
[0027] The scroll direction is configured through the Transform attribute of the animation driving container;
[0028] The scroll rate is configured through the Duration attribute of the DoubleAnimation animation component.
[0029] According to the WPF multi-format content mixed scrolling method provided by the application, the first scroll container and the second scroll container are WPF native container controls.
[0030] The application further provides a WPF multi-format content mixed scrolling device, which comprises:
[0031] A loading module is configured to adapt to a corresponding loading rule according to the type of content to be scrolled, load the content to be scrolled into a first scroll container, and obtain a second scroll container, wherein the content to be scrolled comprises at least one of text, a picture, picture-text mixed layout content and a custom WPF control;
[0032] A comparison module is configured to obtain display size parameters of a display container, and compare the display size parameters with actual size parameters of the second scroll container;
[0033] A generation module is configured to generate a mirror copy of the content to be scrolled in the second scroll container through VisualBrush technology when the actual size parameters are greater than the display size parameters.
[0034] a new module, configured to newly create an animation-driven container, and seamlessly splice the second scroll container and the mirror copy to the animation-driven container;
[0035] an embedding module, configured to embed the animation-driven container into the display container;
[0036] a driving module, configured to drive the animation-driven container to move based on a DoubleAnimation animation component, so that the second scroll container and the mirror copy in the animation-driven container synchronously scroll with the movement.
[0037] The application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the WPF multi-format content mixed scrolling method according to any one of the above when executing the program.
[0038] The application further provides a non-transitory computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to implement the WPF multi-format content mixed scrolling method according to any one of the above.
[0039] The application provides a WPF-based multi-format content mixed scrolling method and device, a WPF-based multi-format content mixed scrolling equipment and a WPF-based multi-format content mixed scrolling storage medium. BRIEF DESCRIPTION OF DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the present application or prior art, the drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0041] Figure 1 is a flowchart of the WPF-based multi-format content mixed scrolling method provided by the application;
[0042] Figure 2 is a structural diagram of the WPF-based multi-format content mixed scrolling device provided by the application;
[0043] Figure 3 Figure 1 is a structural schematic diagram of an electronic device provided by the present application. DETAILED DESCRIPTION
[0044] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0045] It should be noted that, in the description of the embodiments of the present application, the terms “comprise”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement “comprises a” does not exclude the presence of another identical element in the process, method, article or device comprising the element.
[0046] The terms “first”, “second” and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by “first”, “second” and the like are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, “and / or” means at least one of the connected objects, and the character “ / ” generally represents a “or” relationship between the objects before and after it.
[0047] The embodiments of the present application will be described below with reference to the drawings. Figures 1 to 3 A WPF-based multi-format content mixed scrolling method, device, equipment and storage medium are described.
[0048] As shown in Figure 1 The present application provides a WPF-based multi-format content mixed scrolling method, which can be applied to a WPF development environment, relies on WPF native components, API and technical mechanisms for implementation without modifying the underlying code of the WPF framework, and specifically includes the following steps:
[0049] In step 110, the corresponding loading rule is adapted according to the type of the content to be scrolled, the content to be scrolled is loaded into the first scrolling container, and a second scrolling container is obtained, wherein the content to be scrolled includes at least one of text, pictures, picture-text mixed content and custom WPF controls.
[0050] Specifically, both the first and second scroll containers are native WPF container controls such as Grid, Canvas, and StackPanel, possessing content loading and layout adaptation capabilities. Through content type adaptation loading, it ensures that content of different formats can be rendered, laid out, and interacted with correctly within the scroll containers, laying the foundation for subsequent hybrid scrolling.
[0051] The loading rules specifically include:
[0052] For text-based content (including plain text and rich text): Instantiate WPF's native text controls, such as the TextBlock control (for static text display), the TextBox control (for editable text display), and the RichTextBox (for rich text display), configure the font, font size, and color properties, and then add them to the first scroll container;
[0053] For image content (including PNG, JPG, SVG, etc.), instantiate the native WPF Image control, bind the image source (Source property) and set the image stretching mode (Stretch property, such as Uniform mode to ensure that the image ratio remains unchanged), scaling rules, and cropping rules to avoid image distortion. After completion, add the Image control to the first scroll container.
[0054] For content with mixed text and images: First, complete the combined layout of text controls and image controls (such as left image and right text, top text and bottom image, text and image wrapping, etc.) through sub-containers (such as Grid, StackPanel). Then, you can configure the spacing and alignment of controls within the sub-containers and add the entire sub-container to the first scrolling container.
[0055] For custom WPF controls (including business function controls, visually customized controls, and composite interactive controls): business function controls include system status monitoring controls and order information card controls; visually customized controls include gradient style buttons and irregularly shaped image containers; composite interactive controls include link controls with hover tooltips, etc.; instantiate the custom controls created by the developers, initialize the control's business properties (such as binding data sources and setting initial states), and bind interactive events (such as click, hover, and drag events) to ensure that the control has complete business functions and interactive capabilities. After completion, add the custom control to the first scroll container.
[0056] Step 120: Obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container.
[0057] Specifically, the display container is the visible area container for ultimately displaying scrolling content; its size can be fixed or configurable. The display size parameters of the display container can be obtained through WPF's Layout Measurement API. These parameters include width and height. The actual size parameters of the second scrolling container are the same as the actual size parameters of the first scrolling container after loading its content. By comparing the size differences in corresponding dimensions, it is determined whether the content within the second scrolling container exceeds the display area of the display container, thus determining whether the content is displayed scrollably or statically. This adaptive size determination avoids invalid scrolling, improves control efficiency, and ensures the accuracy of the determination results.
[0058] In some embodiments, the comparison rules between the actual size parameter and the display size parameter include:
[0059] If the width of the second scrolling container is greater than the width of the display container, it is determined to be horizontal scrolling;
[0060] If the height of the second scrolling container is greater than the height of the display container, it is determined to be vertical scrolling;
[0061] If the width and height of the second scrolling container are not greater than the width and height of the display container, it is determined to be a static display.
[0062] In this embodiment, the content to be scrolled is further categorized into horizontal scrolling, vertical scrolling, or static display based on a comparison of width and height. The scrolling type determined by the comparison rules also provides a configuration basis for subsequent scrolling direction configuration.
[0063] In some embodiments, if the width and height of the second scrolling container are both greater than the width and height of the display container, scrolling options are output, including horizontal scrolling and vertical scrolling, so that developers can customize the scrolling direction.
[0064] Step 130: When the actual size parameter is greater than the display size parameter, a mirror copy of the content to be scrolled in the second scrolling container is generated using VisualBrush technology.
[0065] Specifically, when the scrolling display is determined, the visual presentation of all content within the second scrolling container is captured using WPF's VisualBrush technology, generating a mirror copy that is visually consistent with the original content (only copying the content visuals, not the container itself), ensuring a seamless transition when the marquee scrolls to the end, thus resolving the scrolling gap issue.
[0066] Step 140: Create a new animation-driven container and seamlessly stitch the second scrolling container and the mirror copy to the animation-driven container.
[0067] Specifically, a dedicated animation-driven container, such as a `TranslateTransform` container, is created to drive scrolling. This container is a WPF instance used to hold the second scroll container and its mirror copy, and to bind the scrolling animation. The second scroll container and its mirror copy are seamlessly joined to the animation-driven container. For example, they are joined horizontally for horizontal scrolling and vertically for vertical scrolling. Furthermore, the scrolling direction can be configured according to business needs, including horizontal left, horizontal right, vertical up, and vertical down, and the scrolling direction can be switched on demand at runtime. By separating the functions of the animation-driven container and the scroll container, flexible configuration of the scrolling logic is achieved.
[0068] Step 150: Embed the animation driving container into the display container.
[0069] Specifically, the animation-driven container needs to be mounted onto a display container (such as a window or the visible area container of a page) and included in the Visual Tree before it can be drawn and displayed on the interface by the WPF rendering engine. The newly added animation-driven container acts as an intermediate layer, carrying the scrolling logic and implementing the marquee scrolling animation effect.
[0070] Step 160: Drive the animation-driven container to move based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation-driven container scroll synchronously as it moves.
[0071] Specifically, based on the WPF DoubleAnimation animation component, the scrolling speed of the content is controlled. DoubleAnimation is a native property animation component in WPF. By modifying the position property of the animation-driving container, the animation-driving container, along with its internal scrolling container and mirror copy, undergoes a positional offset, ultimately creating a visually appealing marquee-like scrolling animation effect.
[0072] In some embodiments, prior to step 160, the following may be included:
[0073] The scrolling direction is configured via the Transform property of the animation-driven container;
[0074] Configure the scrolling rate using the Duration property of the DoubleAnimation animation component.
[0075] In this embodiment, the scrolling direction and speed of the marquee are first configured. Specifically, the scrolling direction is configured through the Transform property of the animation-driven container, which can be configured synchronously when a new animation-driven container is created in step 140. The scrolling speed is configured through the Duration property of the DoubleAnimation animation component. The Duration property value is negatively correlated with the scrolling speed; the smaller the Duration value, the faster the scrolling speed; the larger the Duration value, the slower the scrolling speed.
[0076] First, bind the RenderTransform property (used to control the container's position transformation) of the animation-driven container to the DoubleAnimation animation component to establish the association between the animation and the container's scrolling; set the Duration property value of the DoubleAnimation component according to the preset scrolling rate parameter; finally, start the DoubleAnimation animation to drive the scrolling container and its mirror copy inside the animation-driven container to scroll at a constant speed in the set direction and rate, thereby achieving a continuous loop display of the content.
[0077] It should be noted that the Duration attribute value can be dynamically modified at runtime to achieve real-time control of the scrolling rate and adapt to the display rhythm requirements of different business scenarios, such as slow scrolling for important notifications and fast scrolling for ordinary information.
[0078] To achieve seamless, real-time content updates and improve user experience, in some embodiments, the method further includes:
[0079] Based on the NotifyPropertyChanged data binding mechanism, a real-time association is established between the content to be scrolled in the second scrolling container and the data source;
[0080] When the data source changes, the content to be scrolled in the second scrolling container is automatically refreshed, so that the animation driving container does not need to be redriven.
[0081] In this embodiment, by using WPF's native NotifyPropertyChanged data binding mechanism, a real-time bidirectional association is established between the content to be scrolled within the scrolling container and the backend data source, enabling seamless updates of the marquee scrolling content.
[0082] Specifically, the properties of each content control within the second scrolling container (such as the Text property of TextBlock, the Source property of Image, and the business properties of custom controls) are bound to the data source fields, and the INotifyPropertyChanged interface is implemented. When the data in the data source changes, the property updates and content redraws of the corresponding content controls within the second scrolling container are automatically triggered, eliminating the need for developers to manually write refresh code. After the content redraw is complete, the animation-driven container continues the original scrolling direction and scrolling speed without restarting the scrolling animation, achieving seamless updates of the content to be scrolled. After the content is refreshed, the size comparison in step 120 and the scrolling determination in step 130 can be automatically re-executed. If the content size changes after the refresh (i.e., the text content becomes longer or shorter), the scrolling state can be adaptively adjusted, for example, switching from static display to scrolling display, or from scrolling display to static display, or maintaining the scrolling / static display unchanged.
[0083] It is understandable that when the size of the content to be scrolled is smaller than the size of the display container, there is no need for a marquee scrolling display; instead, a static display is used. Accordingly, in some embodiments, the method further includes: when the actual size parameter is not greater than the display size parameter, embedding the second scrolling container into the display container for static display.
[0084] Specifically, in static display scenarios, no mirror copy of the second scrolling container is generated, nor is an animation-driven container created. Instead, the second scrolling container, loaded with all content, is directly embedded into the visible area of the display container. The second scrolling container serves as the content carrier; its internal text, images, mixed text and image content, and custom WPF controls have already been adapted, loaded, and laid out. The second scrolling container has no positional offset within the display container, and its content remains fixed, resulting in a static display effect.
[0085] Even when statically displayed, the second scrolling container is still bound to the NotifyPropertyChanged data binding mechanism. When the data source is updated, the content in the second scrolling container will be automatically redrawn. After redrawing, the size comparison will be re-executed. If the updated size of the scrolling container is still not larger than the display container, it will continue to maintain a static display; if the size exceeds the display container, it will automatically switch to scrolling mode, generate a mirror copy, create an animation-driven container, and start scrolling.
[0086] The aforementioned WPF-based multi-format content hybrid scrolling method, by loading the content to be scrolled into a scrolling container, supports the mixed loading and scrolling of multiple content formats, including text, images, mixed text and graphics, and custom WPF controls. This solves the technical pain points of traditional WPF scrolling solutions that only support single-format content and that custom business controls cannot adapt to scrolling displays. By comparing the display size parameters of the display container with the actual size parameters of the scrolling container loaded with the content to be scrolled, subsequent scrolling logic is triggered only when the content size exceeds the display range, reducing redundant consumption of system resources such as CPU and memory, and improving control operating efficiency and the rationality of interface display. Finally, VisualBrush technology is used to generate a mirror copy of the content within the scrolling container, which is seamlessly stitched with the original container into the animation-driven container. This invention solves the problem of blank gaps at the end of content scrolling in traditional scrolling solutions, achieving continuous, looping scrolling of content, eliminating visual discontinuity, and significantly improving the user experience. By creating a new animation-driven container as a unified carrier for the scrolling container and its mirror copy, and combining it with the DoubleAnimation component to drive the overall movement of the animation-driven container, the internal content scrolls synchronously. This avoids the problems of asynchronous scrolling and content misalignment that easily occur when driving multiple content controls individually, ensuring the smoothness and stability of the scrolling process. Embedding the animation-driven container into the display container ensures that the scrolling content is always displayed within the user's visible area. Combined with the overall movement logic of the animation-driven container, it achieves visual linkage between "container movement and content scrolling," ensuring an intuitive presentation of the scrolling effect and effective interaction. This invention relies on WPF's native container controls, VisualBrush, DoubleAnimation, and other components, requiring no modification to the underlying WPF framework code. It is highly compatible with existing WPF development environments and project systems, allowing developers to directly integrate it into existing WPF applications, reducing development and migration costs, and possessing strong engineering practicality.
[0087] The following describes the WPF-based multi-format content hybrid scrolling device provided by the present invention. The WPF-based multi-format content hybrid scrolling device described below can be referred to in correspondence with the WPF-based multi-format content hybrid scrolling method described above.
[0088] like Figure 2 As shown, the present invention also provides a WPF-based multi-format content hybrid scrolling device, comprising:
[0089] The loading module 210 is used to adapt the corresponding loading rules according to the type of the content to be scrolled, load the content to be scrolled into the first scroll container, and obtain the second scroll container. The content to be scrolled includes at least one of text, image, mixed text and image content, and custom WPF control.
[0090] The comparison module 220 is used to obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container;
[0091] The generation module 230 is used to generate a mirror copy of the content to be scrolled in the second scrolling container using VisualBrush technology when the actual size parameter is greater than the display size parameter.
[0092] A new module 240 is created to create an animation-driven container and seamlessly stitches the second scrolling container and the mirror copy to the animation-driven container.
[0093] Embedding module 250 is used to embed the animation driving container into the display container;
[0094] The driving module 260 is used to drive the animation driving container to move based on the DoubleAnimation animation component, so as to realize that the second scrolling container and its mirror copy within the animation driving container scroll synchronously as it moves.
[0095] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include: a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a WPF-based multi-format content hybrid scrolling method, which includes:
[0096] According to the type of the content to be scrolled, the corresponding loading rules are adapted, and the content to be scrolled is loaded into the first scroll container to obtain the second scroll container. The content to be scrolled includes at least one of text, images, mixed text and image content, and custom WPF controls.
[0097] Obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container;
[0098] When the actual size parameter is greater than the display size parameter, a mirror copy of the content to be scrolled in the second scrolling container is generated using VisualBrush technology;
[0099] Create a new animation-driven container, and seamlessly stitch the second scrolling container and the mirror copy to the animation-driven container;
[0100] Embed the animation-driven container into the display container;
[0101] The animation-driven container is moved based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation-driven container scroll synchronously as it moves.
[0102] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0103] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is able to execute the WPF-based multi-format content hybrid scrolling method provided by the above methods, the method comprising:
[0104] According to the type of the content to be scrolled, the corresponding loading rules are adapted, and the content to be scrolled is loaded into the first scroll container to obtain the second scroll container. The content to be scrolled includes at least one of text, images, mixed text and image content, and custom WPF controls.
[0105] Obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container;
[0106] When the actual size parameter is greater than the display size parameter, a mirror copy of the content to be scrolled in the second scrolling container is generated using VisualBrush technology;
[0107] Create a new animation-driven container, and seamlessly stitch the second scrolling container and the mirror copy to the animation-driven container;
[0108] Embed the animation-driven container into the display container;
[0109] The animation-driven container is moved based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation-driven container scroll synchronously as it moves.
[0110] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the WPF-based multi-format content hybrid scrolling method provided by the methods described above, the method comprising:
[0111] According to the type of the content to be scrolled, the corresponding loading rules are adapted, and the content to be scrolled is loaded into the first scroll container to obtain the second scroll container. The content to be scrolled includes at least one of text, images, mixed text and image content, and custom WPF controls.
[0112] Obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container;
[0113] When the actual size parameter is greater than the display size parameter, a mirror copy of the content to be scrolled in the second scrolling container is generated using VisualBrush technology;
[0114] Create a new animation-driven container, and seamlessly stitch the second scrolling container and the mirror copy to the animation-driven container;
[0115] Embed the animation-driven container into the display container;
[0116] The animation-driven container is moved based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation-driven container scroll synchronously as it moves.
[0117] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0118] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A WPF-based method for mixed scrolling of multi-format content, characterized in that, include: According to the type of the content to be scrolled, the corresponding loading rules are adapted, and the content to be scrolled is loaded into the first scroll container to obtain the second scroll container. The content to be scrolled includes at least one of text, images, mixed text and image content, and custom WPF controls. Obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container; When the actual size parameter is greater than the display size parameter, a mirror copy of the content to be scrolled in the second scrolling container is generated using VisualBrush technology; Create a new animation-driven container, and seamlessly stitch the second scrolling container and the mirror copy to the animation-driven container; Embed the animation-driven container into the display container; The animation-driven container is moved based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation-driven container scroll synchronously as it moves.
2. The WPF-based multi-format content hybrid scrolling method according to claim 1, characterized in that, Also includes: Based on the NotifyPropertyChanged data binding mechanism, a real-time association is established between the content to be scrolled in the second scrolling container and the data source; When the data source changes, the content to be scrolled in the second scrolling container is automatically refreshed, so that the animation driving container does not need to be redriven.
3. The WPF-based multi-format content hybrid scrolling method according to claim 1, characterized in that, The comparison rules between the actual size parameters and the display size parameters include: If the width of the second scrolling container is greater than the width of the display container, it is determined to be horizontal scrolling; If the height of the second scrolling container is greater than the height of the display container, it is determined to be vertical scrolling; If the width and height of the second scrolling container are not greater than the width and height of the display container, it is determined to be a static display.
4. The WPF-based multi-format content hybrid scrolling method according to claim 3, characterized in that, Also includes: When the actual size parameter is not greater than the display size parameter, the second scrolling container is embedded in the display container for static display.
5. The WPF-based multi-format content hybrid scrolling method according to claim 1, characterized in that, The loading rules include: When the content to be scrolled is text, instantiate a TextBlock, TextBox, or RichTextBox control, configure its font, font size, and color attributes, and then add it to the first scrolling container; When the content to be scrolled is an image, instantiate an Image control, bind the image source, and set the stretching mode and scaling rules before adding it to the first scrolling container; When the content to be scrolled is a combination of text and images, after the text control and image control are combined and laid out through the sub-container, the sub-container is added to the first scrolling container as a whole. When the content to be scrolled is a custom WPF control, the custom control is instantiated, its business properties are initialized, and its interactive events are bound before it is added to the first scrolling container.
6. The WPF-based multi-format content hybrid scrolling method according to claim 1, characterized in that, Before the animation-driven container is moved based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation-driven container scroll synchronously as it moves, the following steps are included: The scrolling direction is configured via the Transform property of the animation-driven container; Configure the scrolling rate using the Duration property of the DoubleAnimation animation component.
7. The WPF-based multi-format content hybrid scrolling method according to any one of claims 1 to 6, characterized in that, The first scroll container and the second scroll container are native WPF container controls.
8. A WPF-based multi-format content hybrid scrolling device, characterized in that, include: The loading module is used to adapt the corresponding loading rules according to the type of the content to be scrolled, load the content to be scrolled into the first scroll container, and obtain the second scroll container. The content to be scrolled includes at least one of text, images, mixed text and image content, and custom WPF controls. The comparison module is used to obtain the display size parameters of the display container and compare them with the actual size parameters of the second scrolling container; The generation module is used to generate a mirror copy of the content to be scrolled in the second scrolling container using VisualBrush technology when the actual size parameter is greater than the display size parameter. A new module is created to create an animation-driven container and seamlessly stitches the second scrolling container and the mirror copy to the animation-driven container. An embedding module is used to embed the animation driving container into the display container; The driving module is used to drive the animation driving container to move based on the DoubleAnimation animation component, so that the second scrolling container and its mirror copy within the animation driving container scroll synchronously as it moves.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the WPF-based multi-format content hybrid scrolling method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the WPF-based multi-format content hybrid scrolling method as described in any one of claims 1 to 7.