locked
Does DeviceInformation.Update() Update?

    Question

  • MSDN documentation says...

    DeviceInformation.Update | update method

    Updates the properties of an existing DeviceInformation object.

    public void Update(
      DeviceInformationUpdate updateInfo
    )

    It kind of sounds like I can use this method to say update a printer display name? If so, how do I initialize a DeviceInformationUpdate object? If not, is there any other way to update a printer display name from a store app?

    Thanks.

    Tuesday, April 01, 2014 11:07 PM

All replies

  • Yes, you can use it to update DeviceInformation. See the list of properties in How to retrieve additional properties for a device or PnP object for the properties you can use, although whether specific properties will work for a given device will depend on the device.

    --Rob

    Tuesday, April 01, 2014 11:54 PM
    Owner
  • Thanks Rob. But how do I create a DeviceInformationUpdate object to pass to Update()?. The Id and Properties properties appear to be read only.
    Wednesday, April 02, 2014 12:07 AM
  • The same way you create any other object:

    DeviceInformationUpdate diu = new DeviceInformationUpdate();

    Collection properties are usually read only: you can't set a new collection on it, but you can query the collection object and then modify its contents.

    diu.Properties.Add(...);
    

    The ID will be set if you're responding to an Updated event.

    --Rob

    Wednesday, April 02, 2014 12:32 AM
    Owner
  • Intellisense did not reveal an Add() method on the Properties property, and the type is a ReadOnlyDictionary.

    Apologies for my ignorance, Rob.

    Wednesday, April 02, 2014 12:38 AM
  • Hey Rob - here's what I get

    • Edited by Sparksteam Wednesday, April 02, 2014 6:06 PM
    Wednesday, April 02, 2014 6:01 PM
  • And I just noticed this error.

    Error 15 The type 'Windows.Devices.Enumeration.DeviceInformationUpdate' has no constructors

    Wednesday, April 02, 2014 6:23 PM
  • What do you say Rob, is this still doable?
    Monday, May 12, 2014 10:36 PM
  • since you can't create the object it looks like you won't be able to update this from the context of a normal app.
    Tuesday, May 13, 2014 7:00 PM
    Owner