foreach (string field in fields) { if (aliases.Keys.Contains(field)) { TextBlock valueBlock = new TextBlock() { TextWrapping = TextWrapping.NoWrap }; Binding valueBinding = new Binding() { Path = new PropertyPath(string.Format("[{0}]", field)), StringFormat = aliases[field] + ": {0}" }; valueBinding.Converter = new DateTimeConverter(); valueBlock.SetBinding(TextBlock.TextProperty, valueBinding); stackBox.Children.Add(valueBlock); } }
public class DateTimeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is DateTime) return (((DateTime)value).Kind != DateTimeKind.Utc) ? ((DateTime)value).ToUniversalTime() : value; else return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value; } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.