MediaQueryList Class

A media query list whose state can be observed (https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface), created by Window.MatchMedia.

public sealed class MediaQueryList : EventTarget

Remarks

The media query list is evaluated against the environment of its document (see ViewportOptions; the viewport of a nested browsing context is the size of its iframe). The change events are fired when the event loop updates the rendering (e.g. before the animation frame callbacks), as specified.

See also

Inheritance
EventTarget MediaQueryList

Properties

NameDescription
MatchesGets whether the media query list matches the environment of the document (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches).
MediaGets the serialized media query list (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media).
OnChangeGets or sets the event handler of the change event.

Gets whether the media query list matches the environment of the document (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches).

public bool Matches { get; }

Gets the serialized media query list (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media).

public string Media { get; }

Gets or sets the event handler of the change event.

public Action<Event>? OnChange { get; set; }

Methods

NameDescription
AddListener(IEventListener?)Adds a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-addlistener).
AddListener(Action<Event>?)Adds a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-addlistener).
RemoveListener(IEventListener?)Removes a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-removelistener).
RemoveListener(Action<Event>?)Removes a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-removelistener).

AddListener overloads

AddListener(IEventListener?)

MediaQueryList.cs

Adds a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-addlistener).

public void AddListener(IEventListener? callback)

AddListener(Action<Event>?)

MediaQueryList.cs

Adds a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-addlistener).

public void AddListener(Action<Event>? callback)
Parameters
callback Action<Event>?

RemoveListener overloads

RemoveListener(IEventListener?)

MediaQueryList.cs

Removes a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-removelistener).

public void RemoveListener(IEventListener? callback)

RemoveListener(Action<Event>?)

MediaQueryList.cs

Removes a listener of the change events (https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-removelistener).

public void RemoveListener(Action<Event>? callback)
Parameters
callback Action<Event>?