Thursday, October 2, 2008

format date in xaml

xmlns:local="clr-namespace:.Utility">






//DateTime format Binding
namespace .Utility
{
///
/// Utility class to convert the date format
///

public class PositionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null)
{
//converts the format during Binding
return String.Format("{0:s}", value).Remove(10);
}
return "";
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{

throw new Exception("The method or operation is not implemented.");
}

}
}

No comments: