private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var message = sender.GetValue(MessageProperty) as string; var plural_message = sender.GetValue(PluralMessageProperty) as string; var modifier = (StringModifier)sender.GetValue(ModifierProperty); var count = 1; if (message == null) { return; } else if (plural_message != null) { count = (int)sender.GetValue(PluralCountProperty); } var localized = plural_message == null ? Vernacular.Catalog.GetString(message) : Vernacular.Catalog.GetPluralString(message, plural_message, count); localized = ModifyString(localized, modifier); localized = Format(localized, count); var property = FindMessageProperty(sender); if (property != null) { sender.SetValue(property, localized); } #if !XAMARINFORMS else if (sender is Run) { (sender as Run).Text = localized; } #endif }
/// <summary> /// Sets a command into the attached property. /// </summary> /// <param name="dependencyObject">The dependency object to assign the command.</param> /// <param name="value">The command to attach.</param> public static void SetCommand(DependencyObject dependencyObject, ICommand value) { if (dependencyObject != null) { dependencyObject.SetValue(CommandProperty, value); } }
public static void SetBackButtonBehavior(BindableObject obj, BackButtonBehavior behavior) => obj.SetValue(BackButtonBehaviorProperty, behavior);
public static void SetShellUnselectedColor(BindableObject obj, Color value) => obj.SetValue(ShellUnselectedColorProperty, value);
public static void SetTabBarDisabledColor(BindableObject obj, Color value) => obj.SetValue(TabBarDisabledColorProperty, value);
public static void SetPluralCount(DependencyObject o, int value) { o.SetValue(PluralCountProperty, value); }
public static void SetComment(DependencyObject o, string value) { o.SetValue(CommentProperty, value); }
public static void SetSearchHandler(BindableObject obj, SearchHandler handler) => obj.SetValue(SearchHandlerProperty, handler);
public static void SetMenu(BindableObject bindable, Menu menu) => bindable.SetValue(MenuProperty, menu);
public static void SetRowSpan(BindableObject bindable, int value) { bindable.SetValue(RowSpanProperty, value); }
public static void SetColumn(BindableObject bindable, int value) { bindable.SetValue(ColumnProperty, value); }
public static void SetItemTemplate(BindableObject obj, DataTemplate itemTemplate) => obj.SetValue(ItemTemplateProperty, itemTemplate);
public static void SetMenuItemTemplate(BindableObject obj, DataTemplate menuItemTemplate) => obj.SetValue(MenuItemTemplateProperty, menuItemTemplate);
public static void SetTitleColor(BindableObject obj, Color value) => obj.SetValue(TitleColorProperty, value);
public static void SetFlyoutBehavior(BindableObject obj, FlyoutBehavior value) => obj.SetValue(FlyoutBehaviorProperty, value);
public static void SetNavBarIsVisible(BindableObject obj, bool value) => obj.SetValue(NavBarIsVisibleProperty, value);
static void OnTransformChanged(BindableObject bindable, object oldValue, object newValue) { if ((string)newValue == "none") { bindable.ClearValue(TranslationXProperty); bindable.ClearValue(TranslationYProperty); bindable.ClearValue(RotationProperty); bindable.ClearValue(RotationXProperty); bindable.ClearValue(RotationYProperty); bindable.ClearValue(ScaleProperty); bindable.ClearValue(ScaleXProperty); bindable.ClearValue(ScaleYProperty); return; } var transforms = ((string)newValue).Split(' '); foreach (var transform in transforms) { if (string.IsNullOrEmpty(transform) || transform.IndexOf('(') < 0 || transform.IndexOf(')') < 0) { throw new FormatException("Format for transform is 'none | transform(value) [transform(value) ]*'"); } var transformName = transform.Substring(0, transform.IndexOf('(')); var value = transform.Substring(transform.IndexOf('(') + 1, transform.IndexOf(')') - transform.IndexOf('(') - 1); double translationX, translationY, scaleX, scaleY, rotateX, rotateY, rotate; if (transformName.StartsWith("translateX", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out translationX)) { bindable.SetValue(TranslationXProperty, translationX); } else if (transformName.StartsWith("translateY", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out translationY)) { bindable.SetValue(TranslationYProperty, translationY); } else if (transformName.StartsWith("translate", StringComparison.OrdinalIgnoreCase)) { var translate = value.Split(','); if (double.TryParse(translate[0], out translationX) && double.TryParse(translate[1], out translationY)) { bindable.SetValue(TranslationXProperty, translationX); bindable.SetValue(TranslationYProperty, translationY); } } else if (transformName.StartsWith("scaleX", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out scaleX)) { bindable.SetValue(ScaleXProperty, scaleX); } else if (transformName.StartsWith("scaleY", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out scaleY)) { bindable.SetValue(ScaleYProperty, scaleY); } else if (transformName.StartsWith("scale", StringComparison.OrdinalIgnoreCase)) { var scale = value.Split(','); if (double.TryParse(scale[0], out scaleX) && double.TryParse(scale[1], out scaleY)) { bindable.SetValue(ScaleXProperty, scaleX); bindable.SetValue(ScaleYProperty, scaleY); } } else if (transformName.StartsWith("rotateX", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out rotateX)) { bindable.SetValue(RotationXProperty, rotateX); } else if (transformName.StartsWith("rotateY", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out rotateY)) { bindable.SetValue(RotationYProperty, rotateY); } else if (transformName.StartsWith("rotate", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out rotate)) { bindable.SetValue(RotationProperty, rotate); } else { throw new FormatException("Invalid transform name"); } } }
public static void SetSetPaddingInsets(BindableObject obj, bool value) => obj.SetValue(SetPaddingInsetsProperty, value);
public static void SetTitleView(BindableObject obj, View value) => obj.SetValue(TitleViewProperty, value);
public static void SetPluralMessage(DependencyObject o, string value) { o.SetValue(PluralMessageProperty, value); }
public static void SetShellForegroundColor(BindableObject obj, Color value) => obj.SetValue(ShellForegroundColorProperty, value);
public static void SetModifier(DependencyObject o, StringModifier value) { o.SetValue(ModifierProperty, value); }
public static void SetShellTabBarTitleColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarTitleColorProperty, value);
public static void SetToolTip(DependencyObject o, string value) { o.SetValue(ToolTipProperty, value); }
public static void SetBackgroundColor(BindableObject obj, Color value) => obj.SetValue(BackgroundColorProperty, value);