using Sledge.UI; public class MyViewportEventListener : IViewportEventListener { public void OnViewportChanged(ViewportEvent e) { // Update the layout or content of the UI element based on the new viewport size } } // Register the event listener with the UI element MyUIElement.ViewportEvent += new MyViewportEventListener().OnViewportChanged;
using Sledge.UI; public class MyViewportEventListener : IViewportEventListener { public void OnViewportChanged(ViewportEvent e) { Console.WriteLine("Viewport changed: {0} x {1}", e.Width, e.Height); } } // Register the event listener with the UI element MyUIElement.ViewportEvent += new MyViewportEventListener().OnViewportChanged;In this example, we define the same event listener class as in Example 1, but instead of updating the UI layout or content, we simply print the new viewport dimensions to the console. This could be useful for debugging or monitoring purposes. Package library: Sledge.UI