Share via


BrightnessOverride.GetForCurrentView Method

Definition

Returns a BrightnessOverride object. This method requires CoreWindow, so it can be used only by apps that are currently running in a window. The returned brightness override object might not be the same between multiple calls to BrightnessOverride.GetForCurrentView on the same thread.

You must call BrightnessOverride.GetForCurrentView from the main UI thread.

public:
 static BrightnessOverride ^ GetForCurrentView();
 static BrightnessOverride GetForCurrentView();
public static BrightnessOverride GetForCurrentView();
function getForCurrentView()
Public Shared Function GetForCurrentView () As BrightnessOverride

Returns

The brightness override object.

Examples

This example shows how apps that run in a window can override the device's brightness at full brightness. To stop the overriding process, use StopOverride.

private void Set_Full_Brightness()
{
    //Create BrightnessOverride object
    BrightnessOverride bo = BrightnessOverride.GetForCurrentView();

    //Set override brightness to full brightness even when battery is low
    bo.SetBrightnessScenario(DisplayBrightnessScenario.FullBrightness, DisplayBrightnessOverrideOptions.None);

    //Request to start the overriding process
    bo.StartOverride();
}

Remarks

This method throws an access-denied exception if there is no CoreWindow on the calling thread.

If you call the StartOverride method on multiple instances in succession, the override with the highest brightness value will take precedence over subsequent calls on instances with lower values. To avoid problems, cache the instance retrieved from BrightnessOverride.GetForCurrentView and reuse that instance, or always call StopOverride on the previously applied BrightnessOverride.

Applies to