0

I can get a non-static property no problem (How to get properties of a class in WinRT), or a static property in c# .net, but can't figure out how to get a static property in C3 winrt.

This is as far as I've gotten. Can anyone help?

            Type type = typeof(ToastNotificationManager);
            var typeInfo = type.GetTypeInfo();
            var historyProperty = type.GetRuntimeProperty("History");
            object history = historyProperty.get
            property.SetValue(obj, value);

I'm trying to reflect for and call ToastNotificationManager.History.Remove() which is only supported on the phone (ToastNotificationManager.History)

Community
  • 1
  • 1
swinefeaster
  • 2,525
  • 3
  • 30
  • 48

1 Answers1

1

This works fine:

PropertyInfo propertyInfo =
    typeof(ToastNotificationManager).GetRuntimeProperty("History");

propertyInfo.SetValue(null, value);

Assuming, of course, that the ToastNotificationManager type has a property named History. :)

Note that when accessing static properties, you simply pass null as the object reference. Since there's no instance connected with a static member, obviously you don't need to pass a reference to one.

Peter Duniho
  • 68,759
  • 7
  • 102
  • 136