Thursday, January 3, 2013
Decimal Value and other type value converter
public class DecimaValuelConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return string.Format("{0:0.00}", value == null ? 0 : value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value;
}
}
------------------------------------------------------------------------------------------------
public class DefaultDateToEmptyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value == null ? String.Empty : value.ToString() == "01/01/0001 12:00:00 AM" ? String.Empty : value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value;
}
}
------------------------------------------------------------------------------------------------------
public class VisibilityConverter : IValueConverter
{
public object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture)
{
bool visibility = (bool)value;
return visibility ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(
object value,
Type targetType,
object parameter,
CultureInfo culture)
{
Visibility visibility = (Visibility)value;
return (visibility == Visibility.Visible);
}
}
-------------------------------------------------------------------------------------------------------
Labels:
Silverlight
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment