Created
September 7, 2012 10:17
-
-
Save pinzolo/3664910 to your computer and use it in GitHub Desktop.
アンダースコアをアンダースコア2つにエスケープするコンバータ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Windows.Data; | |
namespace MktSys.Gui.Converters | |
{ | |
/// <summary> | |
/// アンダースコアを2つにしてエスケープするためのコンバータ | |
/// </summary> | |
/// <remarks>Label や MenuItem のアクセスキー対策</remarks> | |
public class TwiceUnderscoreConverter : IValueConverter | |
{ | |
/// <summary> | |
/// アンダースコアをアンダースコア二つにした文字列に変換する。 | |
/// </summary> | |
/// <param name="value">値</param> | |
/// <param name="targetType">対象の型</param> | |
/// <param name="parameter">パラメータ</param> | |
/// <param name="culture">CultureInfo</param> | |
/// <returns>変換後の文字列</returns> | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
return value == null ? null : value.ToString().Replace("_", "__"); | |
} | |
/// <summary> | |
/// 使用しないため未実装。 | |
/// </summary> | |
/// <param name="value">値</param> | |
/// <param name="targetType">対象の型</param> | |
/// <param name="parameter">パラメータ</param> | |
/// <param name="culture">CultureInfo</param> | |
/// <returns>使用しないため戻り値なし</returns> | |
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment