Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <UserControl x:Class="SilverlightApplication3.MainPage"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:SilverlightApplication3"
- mc:Ignorable="d">
- <Grid x:Name="LayoutRoot">
- <Grid.Resources>
- @@ <local:StringFormatConverter x:Key="StringFormatConverter"></local:StringFormatConverter>
- </Grid.Resources>
- <TextBox x:Name="TxtSource"
- Text="$99"
- Visibility="Collapsed"></TextBox>
- <TextBlock Text="{Binding ElementName=TxtSource,
- Path=Text,
- @@ Converter={StaticResource StringFormatConverter},
- @@ ConverterParameter='The cost is {0} dollars'}">
- </TextBlock>
- </Grid>
- </UserControl>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using System.Windows.Data;
- namespace SilverlightApplication3
- {
- public partial class MainPage : UserControl
- {
- public MainPage()
- {
- InitializeComponent();
- }
- }
- public class StringFormatConverter : IValueConverter
- {
- #region IValueConverter Members
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- @@ return String.Format(parameter.ToString(), value.ToString());
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement