1
// Copyright © Microsoft Corporation.
2
// This source is subject to the Microsoft Source License for Silverlight Controls (March 2008 Release).
3
// Please see http://go.microsoft.com/fwlink/?LinkID=111693 for details.
4
// All other rights reserved.
7
using System.ComponentModel;
8
using System.Collections.Generic;
9
using System.Windows.Controls;
11
namespace System.Windows
14
/// Converts instances of the String type to TextDecorationCollection
17
public sealed partial class TextDecorationCollectionConverter : TypeConverter
20
/// TextDecorationCollection known values.
22
private static Dictionary<string, TextDecorationCollection> KnownValues =
23
new Dictionary<string, TextDecorationCollection>(2, StringComparer.OrdinalIgnoreCase)
25
{ string.Empty, null },
26
{ "Underline", TextDecorations.Underline }
30
/// Initializes a new instance of the TextDecorationCollectionConverter
33
public TextDecorationCollectionConverter()
38
/// Returns a value that indicates whether this converter can convert an
39
/// object of the given type to an instance of TextDecorationCollection.
41
/// <param name="sourceType">
42
/// The type of the source that is being evaluated for conversion.
45
/// true if the converter can convert the provided type to an instance
46
/// of TextDecorationCollection; otherwise, false.
51
public bool CanConvertFrom(Type sourceType)
53
return TypeConverters.CanConvertFrom<TextDecorationCollection>(sourceType);
57
/// Attempts to convert a specified object to an instance of
58
/// TextDecorationCollection.
60
/// <param name="value">The object being converted.</param>
62
/// The instance of TextDecorationCollection created from the converted
68
public object ConvertFrom(object value)
70
return TypeConverters.ConvertFrom<TextDecorationCollection>(this, value);
74
/// Attempts to convert a specified String to an instance of
75
/// TextDecorationCollection.
77
/// <param name="text">
78
/// The String to be converted into the TextDecorationCollection object.
81
/// The instance of TextDecorationCollection created from the converted
87
public object ConvertFromString(string text)
93
return TypeConverters.ConvertFromString(text, KnownValues);