Class Preference.EventContext
Definition
- Namespace:
- Tizen.Applications
- Assembly:
- Tizen.Applications.Preference.dll
The class manages event handlers of the preference keys. It provides functionality to have event handlers for individual preference keys.
public class Preference.EventContext
- Inheritance
-
objectPreference.EventContext
Events
View SourceChanged
Occurs whenever there is a change in the value of a preference key.
Declaration
public event EventHandler<PreferenceChangedEventArgs> Changed
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><PreferenceChangedEventArgs> |
Remarks
This event is raised whenever the value of a preference key changes. It provides information about the changed key through the PreferenceChangedEventArgs argument. The Changed event can be used to keep track of any modifications made to preferences during runtime.
Examples
In this example, we show how to handle the Changed event by printing out the key that was modified. We also demonstrate how to subscribe and unsubscribe from the event.
private static void Preference_PreferenceChanged(object sender, PreferenceChangedEventArgs e)
{
Console.WriteLine("key {0}", e.Key);
}
Preference.EventContext context = null;
Preference.GetEventContext("active_user").TryGetTarget(out context);
if(context != null)
{
context.Changed += Preference_PreferenceChanged;
}
Preference.Set("active_user", "Poe");
Preference.GetEventContext("active_user").TryGetTarget(out context);
if (context != null)
{
context.Changed -= Preference_PreferenceChanged;
}
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the key does not exist or when there is an invalid parameter. |
System.InvalidOperationException | Thrown when the bundle instance has been disposed. |