private void UserControl_Loaded(object sender, RoutedEventArgs e) { GeoPointItem item = this.GeoPointValue; this.txtlat.Text = item.Latitude.ToString(); this.txtlon.Text = item.Longitude.ToString(); }
private void txtlon_TextChanged(object sender, TextChangedEventArgs e) { GeoPointItem item = this.GeoPointValue; item.Longitude = Convert.ToDouble(txtlon.Text); this.GeoPointValue = item; }
//Actual convertion from string to GeoPointItem public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is string) { try { return(GeoPointItem.Parse(value as string)); } catch (Exception ex) { throw new Exception(string.Format("Cannot convert '{0}' ({1}) because {2}", value, value.GetType(), ex.Message), ex); } } return(base.ConvertFrom(context, culture, value)); }
//Actual convertion from GeoPointItem to string public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } GeoPointItem gpoint = value as GeoPointItem; if (gpoint != null) { if (this.CanConvertTo(context, destinationType)) { return(gpoint.ToString()); } } return(base.ConvertTo(context, culture, value, destinationType)); }