Insert new line character to xaml attribute : Xaml « Windows Presentation Foundation « C# / C Sharp






Insert new line character to xaml attribute

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}
&#x000A;.NET Version: {1}
&#x000A;Machine Name: {2}
&#x000A;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

1.Property InheritanceProperty Inheritance
2.Attached PropertiesAttached Properties
3.Property Element SyntaxProperty Element Syntax
4.Embedded Code in Window.xamlEmbedded Code in Window.xaml
5.Xaml Button with namespaceXaml Button with namespace
6.Markup Extensions for ButtonMarkup Extensions for Button
7.Markup Extensions with Property Elements.xamlMarkup Extensions with Property Elements.xaml
8.Inner element with xml namespaceInner element with xml namespace
9.Embedded code for Application
10.Set button properties with Linq styleSet button properties with Linq style
11.Xaml and Code behindXaml and Code behind
12.Use Linq to get control from a containerUse Linq to get control from a container
13.My First WPF App with code behindMy First WPF App with code behind
14.Create Button from Xaml stringCreate Button from Xaml string
15.Reference name defined in Xaml in cs fileReference name defined in Xaml in cs file
16.Type loader with Xaml reader