I have a custom class called AppPreferences. This class has the Color dependency property. This dependency property is an enumerated value of type Colors (which is a regular enumerator). My code for AppPreferences is shown here:
public class AppPreferences { public static readonly DependencyProperty ColorProperty = DependencyProperty.RegisterAttached( "Color", typeof(MyServiceProxy.Colors), typeof(AppPreferences), new PropertyMetadata(MyServiceProxy.Colors.DEFAULT, new PropertyChangedCallback(OnColorChanged)) ); private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
As a developer, I add this to my user interface elements to define color. For example, I will do something like this:
<TextBox custom:AppPreferences.Color="Black" ... />
Now I need to maintain backup colors. In other words, I want to have a comma-separated list of Color values, similar to the one below:
<TextBox custom:AppPreferences.Color="Black,Blue" ... />
My question is: how to update the dependency property and OnColorChanged event handler to support multiple values?
Thanks!
source share