<
TextBlock
>
TextBlock.Text
MultiBinding
StringFormat
=
" {0}, {1}, {2}"
Binding
ElementName
"ThisWindow"
Path
"FirstName"
/>
"MiddleName"
"LastName"
</
public
class
TotalConverter : IMultiValueConverter
{
object
Convert(
[] values, Type targetType,
parameter, System.Globalization.CultureInfo culture)
decimal
Amount = 0;
Discount = 0;
string
TotalAmount =
.Empty;
Amount = (values[0] !=
null
&& values[0] != DependencyProperty.UnsetValue) ? System.Convert.ToDecimal(values[0]) : 0;
Discount = (values[0] !=
&& values[1] != DependencyProperty.UnsetValue) ? System.Convert.ToDecimal(values[1]) : 0;
TotalAmount = System.Convert.ToString(Amount - Discount);
return
TotalAmount;
}
[] ConvertBack(
value, Type[] targetTypes,
throw
new
NotImplementedException();
TextBox
Margin
"2"
MinWidth
"120"
Grid.Row
"1"
Grid.Column
TextBox.Text
Converter
"{StaticResource Totalconverter }"
"Amount"
"Discount"
partial
MainWindow : Window, INotifyPropertyChanged
MainWindow()
InitializeComponent();
private
amount ;
Amount
get
amount; }
set
{ amount = value;
OnPropertyChanged(
);
discount;
Discount
discount; }
{ discount = value;
#region INotifyPropertyChanged Members implementation
event
PropertyChangedEventHandler PropertyChanged;
void
txt)
PropertyChangedEventHandler handle = PropertyChanged;
if
(handle !=
)
handle(
this
,
PropertyChangedEventArgs(txt));
#endregion