■ IValueConverter 인터페이스 : 토글 진리 값 변환자 만들기

----------------------------------------------------------------------------------------------------

using System;

using System.Globalization;

using System.Windows.Data;

 

/// <summary>

/// 토글 진리 값 변환자

/// </summary>

public class ToggleBooleanValueConverter : IValueConverter

{

    //////////////////////////////////////////////////////////////////////////////////////////////////// Method

    ////////////////////////////////////////////////////////////////////////////////////////// Public

 

    // IValueConverter

    #region 변환하기 - Convert(value, targetType, parameter, cultureInfo)

 

    /// <summary>

    /// 변환하기

    /// </summary>

    /// <param name="value"></param>

    /// <param name="targetType">타겟 타입</param>

    /// <param name="parameter">매개 변수</param>

    /// <param name="cultureInfo">CultureInfo 객체</param>

    /// <returns>변환 값</returns>

    public object Convert(object value, Type targetType, object parameter, CultureInfo cultureInfo)

    {

        return !(bool)value;

    }

 

    #endregion

 

    // IValueConverter

    #region 역변환하기 - ConvertBack(value, targetType, parameter, cultureInfo)

 

    /// <summary>

    /// 역변환하기

    /// </summary>

    /// <param name="value"></param>

    /// <param name="targetType">타겟 타입</param>

    /// <param name="parameter">매개 변수</param>

    /// <param name="cultureInfo">CultureInfo 객체</param>

    /// <returns>역변환 값</returns>

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo cultureInfo)

    {

        return !(bool)value;

    }

 

    #endregion

}

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG