April 15, 2019

Detect when a TV is no longer connected to the Xbox via WinRT

Given the Xbox display interface is HDMI-based, your first thought may be to attach to the HdmiDisplayInformation.DisplayModesChanged event. Don't. It doesn't provide enough information to solve this problem. Instead, turn to DeviceInformation.CreateWatcher and an Advanced Query String with the following selector:

System.Devices.InterfaceClassGuid:="{E6F07B5F-EE97-4a90-B076-33F57BF4EAA7}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True

The display device interface will toggle between enabled and disabled states and fire the appropriate watcher events.