Insert new line character to xaml attribute
<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:MyNameSpace.EnvironmentInfo2"
Title="Environment Info">
<Window.Resources>
<src:FormattedMultiTextConverter x:Key="conv" />
</Window.Resources>
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource conv}"
ConverterParameter=
"Operating System Version: {0}

.NET Version: {1}

Machine Name: {2}

User Name: {3}" >
<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}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Window>
//File:Window.xaml.cs
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace MyNameSpace.EnvironmentInfo2
{
public class FormattedMultiTextConverter : IMultiValueConverter
{
public object Convert(object[] value, Type typeTarget,
object param, CultureInfo culture)
{
return String.Format((string) param, value);
}
public object[] ConvertBack(object value, Type[] typeTarget,
object param, CultureInfo culture)
{
return null;
}
}
}
Related examples in the same category