Advertisement
Guest User

Henrik Soderlund

a guest
Jan 18th, 2010
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <UserControl x:Class="SilverlightApplication3.MainPage"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:SilverlightApplication3"
  7. mc:Ignorable="d">
  8. <Grid x:Name="LayoutRoot">
  9.  
  10. <Grid.Resources>
  11. @@ <local:StringFormatConverter x:Key="StringFormatConverter"></local:StringFormatConverter>
  12. </Grid.Resources>
  13.  
  14. <TextBox x:Name="TxtSource"
  15. Text="$99"
  16. Visibility="Collapsed"></TextBox>
  17.  
  18. <TextBlock Text="{Binding ElementName=TxtSource,
  19. Path=Text,
  20. @@ Converter={StaticResource StringFormatConverter},
  21. @@ ConverterParameter='The cost is {0} dollars'}">
  22. </TextBlock>
  23.  
  24. </Grid>
  25. </UserControl>
  26.  
  27.  
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Linq;
  31. using System.Net;
  32. using System.Windows;
  33. using System.Windows.Controls;
  34. using System.Windows.Documents;
  35. using System.Windows.Input;
  36. using System.Windows.Media;
  37. using System.Windows.Media.Animation;
  38. using System.Windows.Shapes;
  39. using System.Windows.Data;
  40.  
  41. namespace SilverlightApplication3
  42. {
  43. public partial class MainPage : UserControl
  44. {
  45. public MainPage()
  46. {
  47. InitializeComponent();
  48. }
  49. }
  50.  
  51. public class StringFormatConverter : IValueConverter
  52. {
  53. #region IValueConverter Members
  54.  
  55. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  56. {
  57. @@ return String.Format(parameter.ToString(), value.ToString());
  58. }
  59.  
  60. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  61. {
  62. throw new NotImplementedException();
  63. }
  64.  
  65. #endregion
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement