첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형

▶ FormattedTextConverter.cs

using System;
using System.Globalization;
using System.Windows.Data;

/// <summary>
/// 포맷 텍스트 변환자
/// </summary>
public class FormattedTextConverter : IMultiValueConverter
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Public

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

    /// <summary>
    /// 변환하기
    /// </summary>
    /// <param name="sourceValueArray">소스 값 배열</param>
    /// <param name="targetType">타겟 타입</param>
    /// <param name="parameter">매개 변수</param>
    /// <param name="cultureInfo">문화 정보</param>
    /// <returns>변환 값</returns>
    public object Convert(object[] sourceValueArray, Type targetType, object parameter, CultureInfo cultureInfo)
    {
        return String.Format((string)parameter, sourceValueArray);
    }

    #endregion

    #region 역변환하기 - ConvertBack(sourceValue, targetTypeArray, parameter, cultureInfo)

    /// <summary>
    /// 역변환하기
    /// </summary>
    /// <param name="sourceValue">소스 값</param>
    /// <param name="targetTypeArray">타겟 타입 배열</param>
    /// <param name="parameter">매개 변수</param>
    /// <param name="cultureInfo">문화 정보</param>
    /// <returns>역변환 값</returns>
    public object[] ConvertBack(object sourceValue, Type[] targetTypeArray, object parameter, CultureInfo cultureInfo)
    {
        return null;
    }

    #endregion
}

 

728x90

 

▶ MainWindow.xaml

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:src="clr-namespace:WpfApplication1"
    Title="환경 정보">
    <Window.Resources>
        <src:FormattedTextConverter x:Key="FormattedTextConverterKey" />
    </Window.Resources>
    <TextBlock>
        <TextBlock.Text>
            <MultiBinding
                Converter="{StaticResource FormattedTextConverterKey}"
                ConverterParameter=
"Operating System Version: {0}
&#x000A;.NET Version: {1}
&#x000A;Machine Name: {2}
&#x000A;User Name: {3}
&#x000A;User Domain Name: {4}
&#x000A;System Directory: {5}
&#x000A;Current Directory: {6}
&#x000A;Command Line: {7}">
                <Binding Source="{x:Static s:Environment.OSVersion       }" />
                <Binding Source="{x:Static s:Environment.Version         }" />
                <Binding Source="{x:Static s:Environment.MachineName     }" />
                <Binding Source="{x:Static s:Environment.UserName        }" />
                <Binding Source="{x:Static s:Environment.UserDomainName  }" />
                <Binding Source="{x:Static s:Environment.SystemDirectory }" />
                <Binding Source="{x:Static s:Environment.CurrentDirectory}" />
                <Binding Source="{x:Static s:Environment.CommandLine     }" />
            </MultiBinding>
        </TextBlock.Text>
    </TextBlock>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요