Class OrientationHelper
Helper class for implementing IOrientation.
public class OrientationHelper
- Inheritance
-
OrientationHelper
- Inherited Members
Examples
private class OrientedView : View, IOrientation
{
private readonly OrientationHelper _orientationHelper;
public OrientedView ()
{
_orientationHelper = new (this);
Orientation = Orientation.Vertical;
_orientationHelper.OrientationChanging += (sender, e) => OrientationChanging?.Invoke (this, e);
_orientationHelper.OrientationChanged += (sender, e) => OrientationChanged?.Invoke (this, e);
}
public Orientation Orientation
{
get => _orientationHelper.Orientation;
set => _orientationHelper.Orientation = value;
}
public event EventHandler<CancelEventArgs<Orientation>> OrientationChanging;
public event EventHandler<EventArgs<Orientation>> OrientationChanged;
public bool OnOrientationChanging (Orientation currentOrientation, Orientation newOrientation)
{
// Custom logic before orientation changes
return false; // Return true to cancel the change
}
public void OnOrientationChanged (Orientation newOrientation)
{
// Custom logic after orientation has changed
}
}
Remarks
Implements the standard pattern for changing/changed events.
Constructors
- OrientationHelper(IOrientation)
Initializes a new instance of the OrientationHelper class.
Properties
- Orientation
Gets or sets the orientation of the View.
Events
- OrientationChanged
Raised when the orientation has changed.
- OrientationChanging
Raised when the orientation is changing. This is cancelable.