public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter is string) { return(new TextBlock() { Text = Lang.GetText((string)parameter) }); } else if (value is string) { return(new TextBlock() { Text = Lang.GetText((string)value) }); } else if (value != null) { return(new TextBlock() { Text = Lang.GetText(value.ToString()) }); } return(value); }
public static void Localize(UIElement control) { if (control != null) { if (!string.IsNullOrEmpty(control.Uid)) { if (control is TextBlock) { var tb = (TextBlock)control; tb.Text = GetText(control.Uid); } else if (control is Page) { var page = (Page)control; page.Title = GetText(control.Uid); } else if (control is HeaderedContentControl) { var hcc = (HeaderedContentControl)control; if (hcc.HasHeader && hcc.Header is string) { hcc.Header = GetText(control.Uid); } } else if (control is ContentControl && ((ContentControl)control).Content is string) { var cc = (ContentControl)control; cc.Content = Lang.GetText(control.Uid); } } if (control is ContentControl && ((ContentControl)control).Content is UIElement) { Localize((UIElement)((ContentControl)control).Content); } else if (control is Decorator) { Localize(((Decorator)control).Child); } else if (control is Page && ((Page)control).Content is UIElement) { Localize((UIElement)((Page)control).Content); } else if (control is Panel) { var panel = (Panel)control; foreach (UIElement child in panel.Children) { Localize(child); } } } }